if object_id('sm_cpu_pfmnc_log') is not null
drop table sm_cpu_pfmnc_log
go
create table sm_cpu_pfmnc_log
(
host_id CHARACTER VARYING(13)
, log_ocr_ymdt datetime
, cpu_idx SMALLINT
, used_rto NUMERIC(20,2)
, idel_rto NUMERIC(20,2)
, user_rto NUMERIC(20,2)
, sys_rto NUMERIC(20,2)
, nice_rto NUMERIC(20,2)
, irq_rto NUMERIC(20,2)
, softirq_rto NUMERIC(20,2)
, io_wait_rto NUMERIC(20,2)
, prv_mde_exec_tm_rto NUMERIC(20,2)
, dly_pcd_call_tm_rto NUMERIC(20,2)
)
--select * from sm_cpu_pfmnc_log
;with nums as (
select 0 a union all select 1 union all select 2 union all select 3 union all select 4 union all
select 5 union all select 6 union all select 7 union all select 8 union all select 9
)
, mm as (select a.a+b.a*10 mm from nums a ,nums b where a.a+b.a*10 < 60)
, hh as (select a.a+b.a*10 hh from nums a ,nums b where a.a+b.a*10 < 24)
, hostname as (select a.a+b.a*10+c.a*100+d.a*1000 hostname from nums a, nums b, nums c, nums d where a.a+b.a*10+c.a*100+d.a*1000 < 2)
insert into sm_cpu_pfmnc_log
select right('000000000000000'+cast(hostname as varchar(100)), 13) host_id
, dateadd(hh, hh, dateadd(mi, mm , getdate())) log_ocr_ymdt
, hh % 8 cpu_idx
, cast(abs(checksum(newid()))/3.33 as numeric(20,2)) used_rto
, cast(abs(checksum(newid()))/3.33 as numeric(20,2)) idel_rto
, cast(abs(checksum(newid()))/3.33 as numeric(20,2)) user_rto
, cast(abs(checksum(newid()))/3.33 as numeric(20,2)) sys_rto
, cast(abs(checksum(newid()))/3.33 as numeric(20,2)) nice_rto
, cast(abs(checksum(newid()))/3.33 as numeric(20,2)) irq_rto
, cast(abs(checksum(newid()))/3.33 as numeric(20,2)) softirq_rto
, cast(abs(checksum(newid()))/3.33 as numeric(20,2)) io_wait_rto
, cast(abs(checksum(newid()))/3.33 as numeric(20,2)) prv_mde_exec_tm_rto
, cast(abs(checksum(newid()))/3.33 as numeric(20,2)) dly_pcd_call_tm_rto
from hostname, hh, mm
order by 2
-- 아래와 같이 파일로 생성
select right(cast(used_rto as varchar(20)),5), * from sm_cpu_pfmnc_log order by log_ocr_ymdt
-- 생성된 파일을 array insert 하기로 함
'밥벌이' 카테고리의 다른 글
OPTIMIZE FOR ( @variable_name { UNKNOWN | = literal_constant } [ , ...n ] ) (0) | 2010.11.19 |
---|---|
민석이의 waitstat 모니터링 (0) | 2010.11.18 |
Array Insert (1) | 2010.11.17 |
이 쿼리의 결과는 뭘까요? (6) | 2010.11.04 |
insert select 로 인해 플랜 공간이 소모됩니다. (0) | 2010.10.28 |