티스토리 뷰
프로젝트의 GS인증을 받기 위해서 TEST 데이터를 생성중이다.
임시테이블을 생성해서 작업을 진행하였다.
1. 임시테이블 생성
기존에 생성되어있는 Procedure를 이용해서 기존테이블의 생성 쿼리를 가져온다.
call sp_table_definition('drive_record_i');
2. 테이블 생성
3. 데이터 생성
-- 기준 테이블 DRIVE_RECORD_I
-- 임시테이블 명 ZZ_TEMP_DRIVE_RECORD_I
-- 기준테이블 조회
select * from DRIVE_RECORD_I;
select count(*) from DRIVE_RECORD_I;
-- 기존 년도별 데이터 확인 코드
select year(strd_dt) year, count(*)
from ZZ_DRIVE_RECORD_I
group by year(strd_dt);
-- 년도별 데이터 확인 코드
select year(strd_dt) year, count(*)
from DRIVE_RECORD_I
group by year(strd_dt) order by year asc;
-- 기준 테이블 DRIVE_RECORD_I
-- 임시테이블 명 ZZ_TEMP_DRIVE_RECORD_I
delete from DRIVE_RECORD_I;
-- 기준 테이블 전체 임시 테이블로 복사
insert into DRIVE_RECORD_I
select * from ZZ_DRIVE_RECORD_I;
-- 2023년 데이터 삭제
delete from DRIVE_RECORD_I where YEAR(STRD_DT) = '2023';
-- 2012년 데이터 삭제
delete from DRIVE_RECORD_I where YEAR(STRD_DT) = '2012';
-- 2022년 데이터 삭제
delete from DRIVE_RECORD_I where YEAR(STRD_DT) = '2022';
-- 윤달 확인
SELECT LAST_DAY('2019/02/07') from dual;
SELECT LAST_DAY('2022/02/07') from dual;
-- 19년 데이터를 22년으로 변경
update DRIVE_RECORD_I set STRD_DT = STRD_DT + (INTERVAL '3'YEAR)
where year(STRD_DT) = '2019';
-- 윤달 확인
SELECT LAST_DAY('2014/02/07') from dual;
SELECT LAST_DAY('2023/02/07') from dual;
-- 14년 데이터를 23년으로 변경
update DRIVE_RECORD_I set STRD_DT = STRD_DT + (INTERVAL '9'YEAR)
where YEAR(STRD_DT) = '2014';
-- 여기까지 진행
--
-- 5월 이후 데이터(14->23)는 delete 내일 6월 이후 데이터 삭제해야함
-- 2023-06-01 ~ 2023-12-31 데이터 삭제
delete from DRIVE_RECORD_I
where STRD_DT >= TO_DATE('2023-06-01', 'YYYY-MM-DD')
and STRD_DT < TO_DATE('2024-01-01', 'YYYY-MM-DD');
-- 삭제 확인
select * from DRIVE_RECORD_I
where STRD_DT >= to_date('2023-06-01');
-- 2단계 일반 데이터 생성
--
-- 년도별 데이터 확인 코드
select FORM_CODE, year(strd_dt) year, count(*)
from DRIVE_RECORD_I
group by FORM_CODE, year(strd_dt) order by year asc;
-- 16년 -> 20년도로 변경
-- nm-01 -> 201, nm-02 -> 202 ... nm-09 -> 209, nm-10 -> 210
-- 2016년 편성별
select FORM_CODE, year(strd_dt) year, count(*)
from DRIVE_RECORD_I
where YEAR(STRD_DT) = '2016'
group by FORM_CODE, year(strd_dt) order by year asc;
update DRIVE_RECORD_I set FORM_CODE = '201'
where FORM_CODE = 'nm-01' and YEAR(STRD_DT) = '2016';
update DRIVE_RECORD_I set FORM_CODE = '202'
where FORM_CODE = 'nm-02' and YEAR(STRD_DT) = '2016';
update DRIVE_RECORD_I set FORM_CODE = '203'
where FORM_CODE = 'nm-03' and YEAR(STRD_DT) = '2016';
update DRIVE_RECORD_I set FORM_CODE = '204'
where FORM_CODE = 'nm-04' and YEAR(STRD_DT) = '2016';
update DRIVE_RECORD_I set FORM_CODE = '205'
where FORM_CODE = 'nm-05' and YEAR(STRD_DT) = '2016';
update DRIVE_RECORD_I set FORM_CODE = '206'
where FORM_CODE = 'nm-06' and YEAR(STRD_DT) = '2016';
update DRIVE_RECORD_I set FORM_CODE = '207'
where FORM_CODE = 'nm-07' and YEAR(STRD_DT) = '2016';
update DRIVE_RECORD_I set FORM_CODE = '208'
where FORM_CODE = 'nm-08' and YEAR(STRD_DT) = '2016';
update DRIVE_RECORD_I set FORM_CODE = '209'
where FORM_CODE = 'nm-09' and YEAR(STRD_DT) = '2016';
update DRIVE_RECORD_I set FORM_CODE = '210'
where FORM_CODE = 'nm-10' and YEAR(STRD_DT) = '2016';
select * from DRIVE_RECORD_I
where STRD_DT >= TO_DATE('2016-01-01', 'YYYY-MM-DD')
and STRD_DT <= TO_DATE('2016-12-31', 'YYYY-MM-DD') and FORM_CODE not LIKE '%nm%';
-- 201-210 편성 데이터만, 16 -> 20년로 년도 변경
update DRIVE_RECORD_I set STRD_DT = STRD_DT + (interval '4'YEAR)
where YEAR(STRD_DT) = '2016' and FORM_CODE not like '%nm%';
select * from DRIVE_RECORD_I
where FORM_CODE not like '%nm%' and YEAR(STRD_DT) = '2020';
-- 17년 -> 21년도로 변경
select FORM_CODE, year(strd_dt) year, count(*)
from DRIVE_RECORD_I
where YEAR(STRD_DT) = '2017'
group by FORM_CODE, year(strd_dt) order by year asc;
update DRIVE_RECORD_I set FORM_CODE = '201'
where FORM_CODE = 'nm-01' and YEAR(STRD_DT) = '2017';
update DRIVE_RECORD_I set FORM_CODE = '202'
where FORM_CODE = 'nm-02' and YEAR(STRD_DT) = '2017';
update DRIVE_RECORD_I set FORM_CODE = '203'
where FORM_CODE = 'nm-03' and YEAR(STRD_DT) = '2017';
update DRIVE_RECORD_I set FORM_CODE = '204'
where FORM_CODE = 'nm-04' and YEAR(STRD_DT) = '2017';
update DRIVE_RECORD_I set FORM_CODE = '205'
where FORM_CODE = 'nm-05' and YEAR(STRD_DT) = '2017';
update DRIVE_RECORD_I set FORM_CODE = '206'
where FORM_CODE = 'nm-06' and YEAR(STRD_DT) = '2017';
update DRIVE_RECORD_I set FORM_CODE = '207'
where FORM_CODE = 'nm-07' and YEAR(STRD_DT) = '2017';
update DRIVE_RECORD_I set FORM_CODE = '208'
where FORM_CODE = 'nm-08' and YEAR(STRD_DT) = '2017';
update DRIVE_RECORD_I set FORM_CODE = '209'
where FORM_CODE = 'nm-09' and YEAR(STRD_DT) = '2017';
update DRIVE_RECORD_I set FORM_CODE = '210'
where FORM_CODE = 'nm-10' and YEAR(STRD_DT) = '2017';
select FORM_CODE, YEAR(STRD_DT) as year from DRIVE_RECORD_I
where STRD_DT >= TO_DATE('2017-01-01', 'YYYY-MM-DD')
and STRD_DT <= TO_DATE('2017-12-31', 'YYYY-MM-DD') and FORM_CODE not LIKE '%nm%'
group by FORM_CODE, YEAR(STRD_DT);
-- 17 -> 21, 201-210
update DRIVE_RECORD_I set STRD_DT = STRD_DT + (interval '4'YEAR)
where YEAR(STRD_DT) = '2017' and FORM_CODE not like '%nm%';
-- 18년 -> 22년도로 변경
select FORM_CODE, year(strd_dt) year, count(*)
from DRIVE_RECORD_I
where YEAR(STRD_DT) = '2018'
group by FORM_CODE, year(strd_dt) order by year asc;
update DRIVE_RECORD_I set FORM_CODE = '201'
where FORM_CODE = 'nm-01' and YEAR(STRD_DT) = '2018';
update DRIVE_RECORD_I set FORM_CODE = '202'
where FORM_CODE = 'nm-02' and YEAR(STRD_DT) = '2018';
update DRIVE_RECORD_I set FORM_CODE = '203'
where FORM_CODE = 'nm-03' and YEAR(STRD_DT) = '2018';
update DRIVE_RECORD_I set FORM_CODE = '204'
where FORM_CODE = 'nm-04' and YEAR(STRD_DT) = '2018';
update DRIVE_RECORD_I set FORM_CODE = '205'
where FORM_CODE = 'nm-05' and YEAR(STRD_DT) = '2018';
update DRIVE_RECORD_I set FORM_CODE = '206'
where FORM_CODE = 'nm-06' and YEAR(STRD_DT) = '2018';
update DRIVE_RECORD_I set FORM_CODE = '207'
where FORM_CODE = 'nm-07' and YEAR(STRD_DT) = '2018';
update DRIVE_RECORD_I set FORM_CODE = '208'
where FORM_CODE = 'nm-08' and YEAR(STRD_DT) = '2018';
update DRIVE_RECORD_I set FORM_CODE = '209'
where FORM_CODE = 'nm-09' and YEAR(STRD_DT) = '2018';
update DRIVE_RECORD_I set FORM_CODE = '210'
where FORM_CODE = 'nm-10' and YEAR(STRD_DT) = '2018';
select FORM_CODE, YEAR(STRD_DT) as year from DRIVE_RECORD_I
where STRD_DT >= TO_DATE('2018-01-01', 'YYYY-MM-DD')
and STRD_DT <= TO_DATE('2018-12-31', 'YYYY-MM-DD') and FORM_CODE not LIKE '%nm%'
group by FORM_CODE, YEAR(STRD_DT);
-- 18 -> 22, 201-210
update DRIVE_RECORD_I set STRD_DT = STRD_DT + (interval '4'YEAR)
where YEAR(STRD_DT) = '2018' and FORM_CODE not like '%nm%';
-- 15년 -> 23년도로 변경
select FORM_CODE, year(strd_dt) year, count(*)
from DRIVE_RECORD_I
where YEAR(STRD_DT) = '2015'
group by FORM_CODE, year(strd_dt) order by year asc;
update DRIVE_RECORD_I set FORM_CODE = '201'
where FORM_CODE = 'nm-01' and YEAR(STRD_DT) = '2015';
update DRIVE_RECORD_I set FORM_CODE = '202'
where FORM_CODE = 'nm-02' and YEAR(STRD_DT) = '2015';
update DRIVE_RECORD_I set FORM_CODE = '203'
where FORM_CODE = 'nm-03' and YEAR(STRD_DT) = '2015';
update DRIVE_RECORD_I set FORM_CODE = '204'
where FORM_CODE = 'nm-04' and YEAR(STRD_DT) = '2015';
update DRIVE_RECORD_I set FORM_CODE = '205'
where FORM_CODE = 'nm-05' and YEAR(STRD_DT) = '2015';
update DRIVE_RECORD_I set FORM_CODE = '206'
where FORM_CODE = 'nm-06' and YEAR(STRD_DT) = '2015';
update DRIVE_RECORD_I set FORM_CODE = '207'
where FORM_CODE = 'nm-07' and YEAR(STRD_DT) = '2015';
update DRIVE_RECORD_I set FORM_CODE = '208'
where FORM_CODE = 'nm-08' and YEAR(STRD_DT) = '2015';
update DRIVE_RECORD_I set FORM_CODE = '209'
where FORM_CODE = 'nm-09' and YEAR(STRD_DT) = '2015';
update DRIVE_RECORD_I set FORM_CODE = '210'
where FORM_CODE = 'nm-10' and YEAR(STRD_DT) = '2015';
select FORM_CODE, YEAR(STRD_DT) as year from DRIVE_RECORD_I
where STRD_DT >= TO_DATE('2015-01-01', 'YYYY-MM-DD')
and STRD_DT <= TO_DATE('2015-12-31', 'YYYY-MM-DD') and FORM_CODE not LIKE '%nm%'
group by FORM_CODE, YEAR(STRD_DT);
-- 15 -> 23, 201-210
update DRIVE_RECORD_I set STRD_DT = STRD_DT + (interval '8'YEAR)
where YEAR(STRD_DT) = '2015' and FORM_CODE not like '%nm%';
-- 23년데이터, 201-210, 6월 이후 삭제
delete from DRIVE_RECORD_I
where STRD_DT >= TO_DATE('2023-06-01', 'YYYY-MM-DD')
and STRD_DT <= TO_DATE('2023-12-31', 'YYYY-MM-DD') and FORM_CODE not LIKE '%nm%'
-- 2013년 데이터 삭제
select * from DRIVE_RECORD_I where year(STRD_DT)='2013';
delete DRIVE_RECORD_I where year(STRD_DT)='2013';
-- 끝
-- 데이터 제대로 들어갔는지 확인
select * from DRIVE_RECORD_I;
select FORM_CODE, year(strd_dt) year, count(*)
from DRIVE_RECORD_I
group by FORM_CODE, year(strd_dt) order by FORM_CODE;
select * from zz_temp_design_rams
-- 생성된 테이블 조회
select * from zz_temp_design_rams;
-- 테이블 데이터 삭제
delete from ZZ_TEMP_DESIGN_RAMS;
-- LBS_TYPE G 제외, LBS_TYPE= null제외 =LBS_NO ROOT 제외, DEL_YN 1 제외
select count(*) from SYS_LBS; -- 357
select LBS_TYPE, count(*) from SYS_LBS
group by LBS_TYPE; -- i 332 null 1 g 8 s 16
select * from SYS_LBS where LBS_TYPE is null;
select LBS_TYPE, count(*) from SYS_LBS
where LBS_TYPE != 'G' and LBS_TYPE is not null
group by LBS_TYPE
;
select * from SYS_LBS
where LBS_TYPE != 'G' and LBS_TYPE is not null and DEL_YN != '1'
;
-- 테이블 복사
insert into ZZ_TEMP_DESIGN_RAMS (LBS_ID, REG_USER_ID)
select LBS_ID, REG_USER_ID from SYS_LBS
where LBS_TYPE != 'G' and LBS_TYPE is not null and DEL_YN != '1'
;
-- 임시테이블에 랜덤값 생성
SELECT DBMS_RANDOM.RANDOM AS RANDOM_NUM FROM DUAL; --(2의 31제곱) 보다 크거나 같고 (2의 31제곱) 보다 작은 임의의 정수를 생성
-- 범위 지정 랜덤값 생성
SELECT DBMS_RANDOM.VALUE(0, 100) FROM DUAL;
-- 소수점 자리 범위 지정
SELECT ROUND(DBMS_RANDOM.VALUE(0, 100)) FROM DUAL;
SELECT ROUND(DBMS_RANDOM.VALUE(50, 150), 6) FROM DUAL;
SELECT ROUND(DBMS_RANDOM.VALUE(20000, 250000), 6) FROM DUAL;
SELECT ROUND(DBMS_RANDOM.VALUE(99, 100), 6) FROM DUAL;
-- 데이터 업데이트
update ZZ_TEMP_DESIGN_RAMS set COMP_QTY= ROUND(DBMS_RANDOM.VALUE(0, 10));
update ZZ_TEMP_DESIGN_RAMS set COMP_QTY = '';
-- LBS, 시스템명, 편성당 수량, 고장률_시간, 고장률_거리, MTBF, MKBF, MCBF, MTTR, 고유가용도, 설계수명
-- 편성당 수량 1 고정
-- 고장률_시간 50.123456 - 150.123456
-- 고장률_거리 50.123456 - 150.123456
-- MTBF 20000.123456 - 250000.123456
-- MKBF 20000.123456 - 250000.123456
-- MCBF 20000.123456 - 250000.123456
-- MTTR 15.123456 - 35.123456
-- 고유가용도 99.123456
-- 편성당 수량 1 고정
update ZZ_TEMP_DESIGN_RAMS set comp_qty= 1;
-- 고장률_시간 50.123456 - 150.123456
update ZZ_TEMP_DESIGN_RAMS set trouble_rt_h = ROUND(DBMS_RANDOM.VALUE(50, 150), 6);
-- 고장률_거리 50.123456 - 150.123456
update ZZ_TEMP_DESIGN_RAMS set trouble_rt_km = ROUND(DBMS_RANDOM.VALUE(50, 150), 6);
-- MTBF 20000.123456 - 250000.123456
update ZZ_TEMP_DESIGN_RAMS set MTBF_VAL = ROUND(DBMS_RANDOM.VALUE(20000, 250000), 6);
-- MKBF 20000.123456 - 250000.123456
update ZZ_TEMP_DESIGN_RAMS set MKBF_VAL = ROUND(DBMS_RANDOM.VALUE(20000, 250000), 6);
-- MCBF 20000.123456 - 250000.123456
update ZZ_TEMP_DESIGN_RAMS set MCBF_VAL = ROUND(DBMS_RANDOM.VALUE(20000, 250000), 6);
-- MTTR 15.123456 - 35.123456
update ZZ_TEMP_DESIGN_RAMS set mttr_val = ROUND(DBMS_RANDOM.VALUE(15, 35), 6);
-- 고유가용도 99.123456
update ZZ_TEMP_DESIGN_RAMS set avail_val = ROUND(DBMS_RANDOM.VALUE(99, 100), 6);
-- 설계수명
update ZZ_TEMP_DESIGN_RAMS set design_life = ROUND(DBMS_RANDOM.VALUE(10, 20));
select * from ZZ_TEMP_DESIGN_RAMS;
SELECT *
FROM SYS_LBS
where del_yn = 1
and sys_lbs_name like '%계수기%'
- Total
- Today
- Yesterday
- yumdownloader
- Postgresql12
- postgis 설치
- SVN
- 공간데이터
- 공간데이터병합
- su postgres 안됨
- yumrepository
- OpenLayers
- Geoserver
- Postgis
- apachepoi
- 엑셀POI
- getCell
- 리눅스
- 부하측정
- shp2pgsql
- createRow
- CreateCell
- 리눅스폐쇄망
- getRow
- Some resources were not updated.
- jdbcType
- 폐쇄망에서패키지설치
- 인터넷안되는환경에서설치
- Centos7에서 Postgresql12 설치
- mybatisif
- setForceFormulaRecalculation
- svn프로젝트불러오기
- 폐쇄망에서rpm설치
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |