1. insert문에 들어가야 할 컬럼을 select문으로 조회한다.
select (select max(fileno)+1 from tb_file_data) + row_number() over(order by t.fileno) as fileno
, t.cntno, 'public', t.orifilename, t.filename, t.filetype, t.filesize
from TB_FILE_DATA t
where code like '%open%'
and delchk = 'N'
2. pk의 무결성제약조건을 만족시키기 위하여 select문으로 조회한 순번만큼 pk값을 더해준다.
(select max(fileno)+1 from tb_file_data) + row_number() over(order by t.fileno)
3. insert문을 생성한다.
insert into TB_FILE_DATA (fileno, cntno, code, orifilename, filename, filetype, filesize)
select (select max(fileno)+1 from tb_file_data) + row_number() over(order by t.fileno) as fileno
, t.cntno, 'public', t.orifilename, t.filename, t.filetype, t.filesize
from TB_FILE_DATA t
where code like '%open%'
and delchk = 'N'
'DataBase' 카테고리의 다른 글
[SQL] 논리적 I/O와 물리적 I/O의 유형 정리 (0) | 2025.03.08 |
---|---|
[SQL] 데이터베이스 저장 구조(Database Storage Structure) (1) | 2025.03.07 |
[SQL] 오라클 SGA(System Global Area) (2) | 2025.03.07 |
[SQL 튜닝/옵티마이저] 🎈오라클 힌트란? 간단한 사용 방법 (0) | 2024.07.08 |
엑셀을 이용한 쿼리문 작성 (0) | 2022.10.12 |