Oracle 쿼리를 PostgreSQL 쿼리로 변경 할때 수정 해야 할 부분입니다.
테이블 이관은 찾아보면 무료로 사용 할 수 있는게 몇가지 있습니다. 적당한 것으로 하시면 될거 같습니다.
Oracle | PostgreSQL | 비고 |
select sysdate FROM DUAL | select now() | |
sysdate | now() | |
ROWNUM | (ROW_NUMBER() OVER()) | select 절 |
WHERE ROWNUM = | LIMIT | where |
NVL | coalesce | |
left outer join (+) | (left table) left outer join (Right table) on left.col = right.col | |
right outer join (+) | (left table) right outer join (Right table) on left.col = right.col | |
inner join | (left table) inner join (Right table) on left.col = right.col | |
connect by | WITH RECURSIVE RC AS ( select Cast(R.MENU_ID as TEXT) as SYS_MENU_PATH, cast(R.MENU_NM as TEXT) as PGM_MENU_PATH, 1 as level,R.MENU_ID, R.MENU_NM, R.UPPER_MENU_ID FROM EO_MENU R WHERE R.UPPER_MENU_ID = 206 UNION all select Cast((RC.SYS_MENU_PATH ||';'|| R.MENU_ID) as TEXT) as SYS_MENU_PATH , cast(RC.PGM_MENU_PATH ||'>'|| R.MENU_NM as text) as PGM_MENU_PATH, RC.level +1 as level, R.MENU_ID,R.MENU_NM,R.UPPER_MENU_ID from EO_MENU R join RC on RC.MENU_ID = R.UPPER_MENU_ID ) (case when (select distinct RC.MENU_ID from RC leaf where leaf.UPPER_MENU_ID=RC.MENU_ID) is null then 1 else 0 end) as is_leaf |
계층구조 데이터 |
to_number | ::numeric to_number('123','999') , to_number('1234','99999999') cast(xxxx as text) |
숫자변환 |
decode | case when then else end | |
ADD_MONTHS(sysdate),-1) | now() + interval '-1 month' | |
SEQ_EO_COUPONTYPE_00.NEXTVAL | NEXTVAL('SEQ_EO_COUPONTYPE_00') | Sequence |
MERGE INTO COMTNAUTHORINFO USING DUAL ON (AUTHOR_CODE = 'ROL_TEST1') WHEN MATCHED THEN UPDATE SET AUTHOR_NM = '테스트권한' ,AUTHOR_DC = '테스트권한' ,AUTHOR_CREAT_DE = '2020-09-01' WHEN NOT MATCHED THEN INSERT (AUTHOR_CODE, AUTHOR_NM, AUTHOR_DC, AUTHOR_CREAT_DE) VALUES ('ROL_TEST', '테스트권한1', '테스트권한1', SYSDATE); |
WITH UPSERT AS( UPDATE comtnauthorinfo SET author_nm = '테스트권한' ,author_dc = '테스트권한' ,author_creat_de = '2020-09-01' WHERE author_code = 'ROL_TEST' RETURNING * ) INSERT INTO comtnauthorinfo (author_code, author_nm, author_dc, author_creat_de) SELECT 'ROL_TEST', '테스트권한1', '테스트권한1', CURRENT_TIMESTAMP WHERE NOT EXISTS(SELECT * FROM UPSERT); |
merge into |
'DB' 카테고리의 다른 글
PostgreSQL Table 목록 추출 (0) | 2023.04.11 |
---|---|
Oracle Table 목록 추출 (0) | 2023.04.11 |
Postgresql pgpool을 활용한 클러스터 명령어 및 docker-compose (0) | 2023.04.10 |
Postgresql pgpool을 활용한 클러스터링 (0) | 2023.04.10 |
MongoDB Replicaset 구성 명령어 (0) | 2023.04.07 |