93 lines
1.9 KiB
Markdown
93 lines
1.9 KiB
Markdown
|
```sql
|
||
|
|
||
|
|
||
|
/*
|
||
|
1. 테이블정의서 취합
|
||
|
2. 컬럼 정리, No null 확인
|
||
|
3. 맨압 컬럼 seq 순번
|
||
|
|
||
|
*/
|
||
|
|
||
|
truncate table tbl_info
|
||
|
|
||
|
select *
|
||
|
from tbl_info
|
||
|
|
||
|
|
||
|
update tbl_info
|
||
|
set seq = tbl_desc
|
||
|
|
||
|
|
||
|
delete
|
||
|
from tbl_info
|
||
|
where tbl_no = 'No'
|
||
|
|
||
|
|
||
|
delete
|
||
|
from tbl_info
|
||
|
where col_id is null
|
||
|
and tbl_no is null
|
||
|
|
||
|
|
||
|
select count(*)
|
||
|
from tbl_info
|
||
|
|
||
|
select row_number() over(order by cast(seq as integer)) as rownum, seq -- 시작순번
|
||
|
, nvl(LEAD(seq) OVER(order by cast(seq as integer)), 1867 +1)-1 as next_seq -- 마지막순번
|
||
|
, col_nm, idx
|
||
|
from tbl_info ti
|
||
|
where tbl_no ='테이블ID(물리명)'
|
||
|
order by cast(seq as integer)
|
||
|
|
||
|
-- tbl id, tbl name
|
||
|
update tbl_info a,
|
||
|
(
|
||
|
select row_number() over(order by cast(seq as integer)) as rownum, seq -- 시작순번
|
||
|
, nvl(LEAD(seq) OVER(order by cast(seq as integer)), 1867 +1)-1 as next_seq -- 마지막순번
|
||
|
, col_nm, idx
|
||
|
from tbl_info ti
|
||
|
where tbl_no ='테이블ID(물리명)'
|
||
|
order by cast(seq as integer)
|
||
|
) b
|
||
|
set a.tbl_id = b.col_nm,
|
||
|
a.tbl_nm = b.idx
|
||
|
where a.seq >= b.rownum
|
||
|
and a.seq <= b.next_seq
|
||
|
|
||
|
|
||
|
-- tbl_desc
|
||
|
update tbl_info a,
|
||
|
(
|
||
|
select row_number() over(order by cast(seq as integer)) as rownum, seq -- 시작순번
|
||
|
, nvl(LEAD(seq) OVER(order by cast(seq as integer)), 1867 +1)-1 as next_seq -- 마지막순번
|
||
|
, col_nm, idx
|
||
|
from tbl_info ti
|
||
|
where tbl_no ='테이블 설명'
|
||
|
order by cast(seq as integer)
|
||
|
) b
|
||
|
set a.tbl_desc = b.col_nm
|
||
|
where a.seq >= b.rownum
|
||
|
and a.seq <= b.next_seq
|
||
|
|
||
|
|
||
|
-- user, tblspace
|
||
|
update tbl_info a,
|
||
|
(
|
||
|
select row_number() over(order by cast(seq as integer)) as rownum, seq -- 시작순번
|
||
|
, nvl(LEAD(seq) OVER(order by cast(seq as integer)), 1867 +1)-1 as next_seq -- 마지막순번
|
||
|
, col_nm, idx
|
||
|
from tbl_info ti
|
||
|
where tbl_no ='데이터베이스명'
|
||
|
order by cast(seq as integer)
|
||
|
) b
|
||
|
set a.tbl_user = b.idx
|
||
|
, tbl_space = b.col_nm
|
||
|
where a.seq >= b.rownum
|
||
|
and a.seq <= b.next_seq
|
||
|
|
||
|
|
||
|
delete
|
||
|
from tbl_info
|
||
|
where tbl_no in ('테이블ID(물리명)','데이터베이스명','테이블 설명')
|
||
|
|
||
|
```
|