Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2....

28
© 2014 EDB All rights reserved. 1 Oracle to PPAS Migration Best Practice Jihoon Kim, EnterpriseDB Korea 2014.12.02 V03 – Aug 2013

Transcript of Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2....

Page 1: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 1

Oracle to PPAS Migration Best Practice Jihoon Kim, EnterpriseDB Korea

2014.12.02

V03 – Aug 2013

Page 2: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 2

•  Overview •  Migration Preparation •  O2PM

•  DBLINK_ORA •  MTK Options •  Known Incompatible Features

•  Appendix

Agenda

Page 3: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 3

EDB Positioned in Leaders Quadrant in Gartners Magic Quadrant (Oct. 2014)

Gartner Comments:

•  Community leadership — EnterpriseDB 사는 PostgreSQL 커뮤니티의 제 1의 기여자로서 JSON과 같은 PostgreSQL의 수많은 신기능 개발에 참여 및 기여하고 있음.

•  Functionality —EnterpriseDB의 Postgres Plus 의 기능은 엄청나게 발전하였고, Oracle 호환성과 같은 기능은 이미 mission-critical 업무 시스템에서 운영되기에 충분한 수준에 다다름.

•  Stability and compatibility — 수 많은 사례를 통해 이미 Oracle 호환성 기능의 안정성이 입증이 되었고, 강력한 지원 체계의 확보하고 있음.

Page 4: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 4

마이그레이션 절차

호환성 검증

• 스키마 & SQL 사전 검증 • 전환 공수 산정

마이그레이션

• 비호환 구문 workaround 적용 • 데이터 이관 성능 최적화

이행

• 다운 타임 최소화 • 서비스 이관

Page 5: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 5

Oracle Migration Assessment

Oracle

1. Oracle Schema Layout 의 PPAS 호환성 분석

2. Oracle client application에서 사용된 기능 분석

3. 검증된 알고리즘을 통해 5가지 항목으로 결과 분석

Difficult Easy

4. Migration 계획 수립 – 호환성 스코어 및 workaround 적용 등을 고려한 M/M 산정

Page 6: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 6

•  Online Migration Toolkit 쉽고 편한 Oracle Migration 지원

•  자동화된 Migration 지원 :

Database Migration Toolkit

u  Data u  Schemas u  Stored Procedures u  Triggers u  Functions

u  Sequences u  Packages u  Views u  Database Links u  Synonyms

Page 7: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 7

•  JDK 1.6 이상 −  MTK 는 JDBC 기반 프로그램 −  PPAS 설치 단계에서 JDK 설치 여부 확인

•  Oracle Instant Client 11gR2 최신 버전 −  MTK 옵션 중 copyViaDBLinkOra 사용 시 OCI 라이브러리 필요

Preparations – S/W 측면

Page 8: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 8

•  DDL from Oracle −  사전 검증 단계에서 스키마 상의 비호환 구문 등의 확인 −  MTK 버그 등으로 인해 procedure 등의 구문이 완전하지 않은 경우 참조용

•  DDL 추출 예시 −  expdp system/oracle directory=mig dumpfile=example.dmp

schemas=oe,sh,hr content=metadata_only exclude=statistics −  impdp system/oracle directory=mig sqlfile=example.sql

dumpfile=example.dmp

•  V$SQLAREA −  MTK는 스키마와 데이터의 이관만 지원 −  사용중인 SQL 구문상의 비호환 구문 등의 확인

Preparations - Oracle 측면

Page 9: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 9

•  목적 −  데이터 이관 시, MTK의 JDBC 방식 대비 나은 성능의 확보 −  LOB 데이터 처리

•  설정 −  Oracle Instant Client 이용 −  LD_LIBRARY_PATH에 오라클 클라이언트 경로 지정 −  $PGDATA/postgresql.conf 파일의 ‘oracle_home’ 파라미터에 오라클 클라이언트 경로 지정

−  PPAS Bounce

OCI Configuration

Page 10: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 10

O2PM 상세 절차

1. 키워드 �검색

2. PPAS 유저/스키마 생성

3. 스키마 only이관

4. Workaround 적용

5. 데이터 이관

6. 마이그레이션 검증

Page 11: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 11

과정 실행 내용

1. 키워드 검색 - 스키마 & SQL 호환성 검증

1. 오라클에서 DDL 추출 $ expdp system/oracle directory=o2pm dumpfile=soe.dmp schemas=soe content=metadata_only exclude=statistics $ impdp system/oracle directory=o2pm sqlfile=soe.sql dumpfile=soe.dmp 2. 비호환 키워드로 조회 $ grep -i merge soe.sql $ grep -i connect_by soe.sql $ grep -i rollup soe.sql $ grep -i cube soe.sql $ grep -i grouping soe.sql $ grep -i dbms_ soe.sql | grep -v -i dbms_output $ grep -i autonomous soe.sql $ grep -i offset soe.sql $ grep -i limit soe.sql $ grep -i “force view” soe.sql 3. V$SQLAREA 조회 SQL> select * from v$sqlarea where parsing_schema_name='SOE' and lower(sql_fulltext) like ’%merge%'; SQL> select * from v$sqlarea where parsing_schema_name='SOE' and lower(sql_fulltext) like ’%connect_by%’; SQL> select * from v$sqlarea where parsing_schema_name='SOE' and lower(sql_fulltext) like ’%rollup%’; SQL> select * from v$sqlarea where parsing_schema_name='SOE' and lower(sql_fulltext) like ’%cube%’; SQL> select * from v$sqlarea where parsing_schema_name='SOE' and lower(sql_fulltext) like ’%grouping%’; SQL> select * from v$sqlarea where parsing_schema_name='SOE' and lower(sql_fulltext) like ’%offset%’; SQL> select * from v$sqlarea where parsing_schema_name='SOE' and lower(sql_fulltext) like ’%limit%’;

O2PM 예시

Page 12: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 12

과정 실행 내용

2. PPAS 유저/스키마 생성

$ psql edb=# create user soe password ‘ppas’; edb=# create schema soe authorization soe;

3. 스키마 only 이관

$ cd $EDBHOME/bin $ ./runMTK.sh -schemaOnly soe Source database connectivity info... conn =jdbc:oracle:thin:@localhost:1521:orcl user =system password=****** Target database connectivity info... conn =jdbc:edb://localhost:5444/edb user =soe password=****** Connecting with source Oracle database server... Connecting with target EnterpriseDB database server... Importing redwood schema soe... Creating Sequence: ADDRESS_SEQ Creating Sequence: CARD_DETAILS_SEQ Creating Sequence: CUSTOMER_SEQ Creating Sequence: LOGON_SEQ Creating Sequence: ORDERS_SEQ Creating Tables... Creating Table: ADDRESSES Creating Table: CARD_DETAILS Creating Table: CUSTOMERS …………. 중략 …………

O2PM 예시

Page 13: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 13

과정 실행 내용

3. 스키마 only 이관 (계속)

One or more schema objects could not be imported during the migration process. Please review the migration output for more details. Migration logs have been saved to /opt/PostgresPlus/9.3AS/.enterprisedb/migration-toolkit/logs ******************** Migration Summary ******************** Sequences: 5 out of 5 Tables: 11 out of 11 Constraints: 20 out of 20 Indexes: 19 out of 19 Views: 1 out of 2 Packages: 0 out of 1 Users: 0 out of 1 Total objects: 59 Successful count: 56 Failure count: 3 List of failed objects ====================== Views -------------------- 1. SOE.PRODUCTS Packages -------------------- 1. SOE.ORDERENTRY Users -------------------- 1. SOE

O2PM 예시

Page 14: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 14

과정 실행 내용

4. Workaround 적용

1. 원인 분석 -- ORDERENTRY Package 중 (SELECT /*+ materialize CARDINALITY(12) */ (rownum*(1/288)) offset FROM dual CONNECT BY rownum <= 12) 와 같은 구문 발견 2. Workaround 적용 PPAS에서는 “connect by” 구문이 지원되나 dummy로 여러 row를 생성하는 형태로는 지원하지 않음. 또한 “offset” 을 결과값의 alias 로 지정을 하였는데, 이는 PPAS의 예약어임. 이러한 경우 아래와 같이 수정 select (x*(1/288)) as offset from generate_series(1,12) x;

5. 데이터 이관

$ cd $EDBHOME/bin $ ./runMTK.sh -dataOnly –fastCopy soe Source database connectivity info... conn =jdbc:oracle:thin:@localhost:1521:orcl user =system password=****** Target database connectivity info... conn =jdbc:edb://localhost:5444/edb user =soe password=****** Connecting with source Oracle database server... Connecting with target EnterpriseDB database server... Importing redwood schema soe... Loading Table Data in 8 MB batches... Loading Table: ADDRESSES ... [ADDRESSES] Migrated 89457 rows. [ADDRESSES] Migrated 178729 rows. ……….. 중략 …………..

O2PM 예시

Page 15: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 15

과정 실행 내용

5. 데이터 이관 (계속)

………… 중략 ………….. [WAREHOUSES] Table Data Load Summary: Total Time(s): 0.019 Total Rows: 1000 Total Size(MB): 0.025390625 Data Load Summary: Total Time (sec): 432.922 Total Rows: 13250837 Total Size(MB): 984.547 Schema soe imported successfully. Migration process completed successfully. Migration logs have been saved to /opt/PostgresPlus/9.3AS/.enterprisedb/migration-toolkit/logs ******************** Migration Summary ******************** Tables: 11 out of 11 Total objects: 11 Successful count: 11 Failure count: 0

6. 마이그레이션 검증

실제 어플리케이션을 적용하여 1.  기능 검증 2.  성능 확인 및 튜닝

O2PM 예시

Page 16: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 16

•  MTK의 copyViaDBLinkOra 옵션 사용 시, 내부적으로 dblink_ora 함수를 호출함

•  사용 목적 −  LOB 데이터를 이관해야 할 때 −  MTK를 사용하지 않고 오라클의 특정 데이터를 가져와야 하는 경우

•  사용 함수 −  dblink_ora_connect(Link Name, Hostname, Service Name,

User Name, User Password, Port, isDBA) −  dblink_ora_copy(Link Name, SQL SELECT statement,

Destination Schema Name, Destination Table Name, Truncate Table, Feedback Count)

−  dblink_ora_disconnect(Link Name)

DBLINK_ORA 함수

Page 17: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 17

•  세션 레벨 DB Link 생성

•  데이터 이관

DBLINK_ORA 함수 사용 예시

edb=# select dblink_ora_connect (‘oralink’, ‘172.16.181.215’, ‘orcl’, ‘soe’, ‘ppas’, 1521, false);

dblink_ora_connect

---------------------------

OK

(1 row)

edb=# select dblink_ora_copy (‘oralink’, ‘select * from products partition (p1)’, ‘soe’, ‘products_p1’, true, 5000);

INFO: ROW 0

……………….

INFO: ROW 35000

dblink_ora_copy

-----------------------

36321

(1 row)

Page 18: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 18

Feature Options Offline Migrations -offlineMigration

Import -sourcedbtype, -targetdbtype, -schemaOnly, -dataOnly

Schema Creation -dropSchema, -targetSchema

Schema Object Selection -allTables, -tables, -importPartitionAsTable, -constraints, -ignoreCheckConstFilter, -skipCKConst, -skipFKConst, -skipColDefaultClause, -indexes, -triggers, -allViews, -views, -allSequences, -sequences, -allProcs, -procs, -allFuncs, -funcs, -checkFunctionBodies, -allPackages, -packages, -allRules

Migration -truncLoad, -enableConstBeforeDataLoad, -retryCount, -safeMode, -fastCopy, -analyze, vacuumAnalyze, -replaceNullChar, -copyDelimiter, -batchSize, -cpBatchSize, -fetchSize, -filterProp -customColTypeMapping, -customColTypeMappingFile

Oracle Specific -allUsers, -users, -objectTypes, -copyViaDBLinkOra, -allDBLinks -allSynonyms, -allPublicSynonyms, -allPrivateSynonyms

Miscellaneous -help, -logDir, -logFileCount, -logFileSize, -verbose, -version

전체 MTK Options

Page 19: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 19

Options Description

-offlineMigration It generates a set of SQL scripts that will recreate the data and/or schema objects in the target database

-fastCopy Including the -fastCopy option specifies that Migration Toolkit should bypass WAL logging to perform the COPY operation in an optimized way, default disabled

-copyViaDBLinkOra

The dblink_ora module provides EnterpriseDB to Oracle connectivity at the SQL level. dblink_ora is bundled and installed as part of the EnterpriseDB database installation. dblink_ora utilizes the COPY API method to transfer data from an Oracle database to EnterpriseDB database and is considerably faster than the JDBC COPY method.

-schemaOnly This option imports the schema definition and creates all selected schema objects in the target database

-dataOnly This option copies the table data only. When used with the '-tables' option, Migration Toolkit will only import data for the selected tables

-safeMode Migration Toolkit commits each row as migrated; if the migration fails to transfer all records, rows inserted prior to the point of failure will remain in the target database

-importPartitionAsTable Import the contents of a partitioned table into a single non-partitioned table

* $EDBHOME/doc/README-mtk.txt 참조

주요 MTK Options

Page 20: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 20

•  MERGE INTO •  GROUPING SETS, ROLLUP, CUBE

−  PPAS 9.4 지원 예정

•  PRAGMA AUTONOMOUS TRANSACTION •  LIMIT, OFFSET 등과 같은 예약어

•  PPAS에서 지원되는 20개 오라클 패키지 외 DBMS_, UTL_ 패키지 −  DBMS_OBFUSCATION, DBMS_APPLICATION_INFO 등

Known Incompatible Features

Page 21: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 21

Appendix

Page 22: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 22

•  Null값이 포함된 연산은 결과 NULL •  문자 || NULL 값은 문자만 출력 (오라클과 동일) •  오라클에서는 ‘’ 값을 NULL로 인식하나 PPAS에서는 값 (공백)으로 인식 •  오라클은 Date 형 타입에 입력 시 ‘’을 입력하면 NULL로 입력되지만,

PPAS에서는 ‘’ 사용 불가. 명시적으로 NULL 로 입력해야함 •  예시

−  INSERT INTO test VALUES (‘’, NULL);

PPAS 특성 - NULL

SQL ORACLE PPAS

select count(*) from test where a = ‘’ 0 1

select count(*) from test where a is null 1 0

select count(*) from test where b = ‘’ 0 0

select count(*) from test where b is null 1 1

Page 23: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 23

•  테이블 및 칼럼 대소문자 구분 −  테이블명이 오라클은 대문자인 반면 PPAS는 소문자 리턴하는 문제 −  대문자로 사용하고 하는 경우는 테이블 생성시 “TABLE_NAME” 이렇게 생성해 주어야 대문자로 사용이 가능

−  Oracle은 ""를 안붙여 주면 대문자로 치환, PPAS는 ""를 안 붙여 주면 소문자로 치환

•  자동 형 변환 문제 −  PPAS에서 숫자 형이라고 인식하는 경우는 공백문자(스페이스,탭,줄 바꿈 문자)로 시작하거나, 음수 기호가 있거나, 곧이어 공백 없이 숫자로 연속되거나, 그 사이 소수점이 있거나, 그 숫자들 뒤에 공백문자가 있거나 없거나 이렇게 구성된 문자열은 숫자로 판단

−  즉, 1,‘ 1 ‘,‘1 ‘,‘1‘모두1로처리를해야할상황이면숫자1로처리 −  숫자의 문자열 표현식의 형 변환 순서는 첫번째 int4 (int) 그보다 크면, int8

(bigint) 그보다 크면 numeric 으로 변환 −  소수점이 있는 문자열은 무조건 numeric

PPAS 특성 – Data Type

Page 24: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 24

•  CHAR & VARCHAR & VARCHAR2

PPAS 특성 – Data Type

create table test4(i int, x varchar(10), y char(10),z varchar2(10)); insert into test4(i,x,y,z) values(1, 'abc', 'abc', 'abc'); insert into test4(i,x,y,z) values(2, 'abc ', 'abc', 'abc'); insert into test4(i,x,y,z) values(3, 'abc ', 'abc ', 'abc'); insert into test4(i,x,y,z) values(4, 'abc ', 'abc ', 'abc '); insert into test4(i,x,y,z) values(5, 'abc', ' abc ', ' abc ');

select i, length(x), length(y), length(z) from test4 order by i; I x y z -----------|----------|-----------| 1 3 10 3 2 7 10 3 3 7 10 3 4 5 10 5 5 3 10 10 select i,x,y,z from test4 where x=y; no rows selected select i,x,y,z from test4 where x=z; I X Y Z ---------- ---------- ---------- ---------- 1 abc abc abc 4 abc abc abc select i,x,y,z,a from test4 where y=z; I X Y ---------- ---------- ---------- 5 abc abc

test=# select i, length(x), length(y), length(z) from test4 order by i; i | length | length | length ---+--------+--------+-------- 1 | 3 | 3 | 3 2 | 7 | 3 | 3 3 | 7 | 3 | 3 4 | 5 | 3 | 5 5 | 3 | 5 | 10 test=# select i,x,y,z from test4 where x=y; i | x | y | z ---+---------+------------+------- 1 | abc | abc | abc 2 | abc | abc | abc 3 | abc | abc | abc 4 | abc | abc | abc test=# select i,x,y,z from test4 where z=x; i | x | y | z ---+-------+------------+------- 1 | abc | abc | abc 4 | abc | abc | abc

Page 25: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 25

PPAS 특성 – Data Type Type 설명 예시 오라클 PPAS

varchar(10) 가변길이 10byte 만큼 저장할 수 있으나 실제 입력된 길이 만큼만 저장

‘abc’ 실제 입력된 값만큼 length

‘abc ‘ 공백 포함한 실제 입력된 값만큼 length

char(10) 고정 길이 10byte를 미리 할당

‘abc’

무조건 고정 크기이므로 length 동일

실제 문자가 입력된 크기만큼 length

‘abc ’ 뒤의 공백을 제외하고 입력된 만큼 length

‘abc ’

뒤의 공백을 제외하고 앞의 입력된 크기만큼 length ‘ abc ’

varchar2(10) 가변 길이 10byte 만큼 저장할 수 있으나 실제 입력된 길이 만큼만 저장

‘abc’ 실제 입력된 값만큼 length

‘abc ’ 공백 포함한 실제 입력된 값만큼 length

Page 26: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 26

•  PPAS의 기본 날짜 / 시간 자료형 −  Date : 날짜형 (내부적으로 timestamp without time zone 자료형으로 처리) −  Time : 시각형 −  Timestamp:날짜 시각형(timestamp with time zone, timestamp without time zone 두개로 구분) −  Interval : 시간형 −  연산 비교

−  위 오라클과 달리 처리되는 연산들은 오라클의 number 형으로 만들 수 있도록 처리 필요

PPAS 특성 – Data Type

-- For oracle select sysdate - ( sysdate – interval ‘2’ hour ) from dual SYSDATE – ( SYSDATE – INTERVAL ‘2’ HOUR) ----------------------------------------------------- 0.0833333333333333333333333333333333333

-- For PG select (extract(epoch from sysdate) – extract(epoch from (sysdate – interval ‘2’ hour)))::number / 86400 from dual; ------------------------------------------------------------- 0.0833333333333333333333333333333333333

구분 결과 비고 Date vs Date interval 오라클에서는 number자료형으로 리턴

Date +- integer, numeric timestamp 오라클과 동일

Date +- interval timetamp

Timestamp vs Timestamp interval 오라클에서는 number 자료형으로 리턴

Timestamp +- integer, numeric timestamp 오라클과 동일

Timestamp +- interval timestamp

Page 27: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 27

•  주요 Date / Time Functions −  select sysdate() : 16-JAN-13 15:33:06 (오라클과 동일) −  select now() : 16-JAN-13 15:33:28.540218 +09:00 (now()는 날짜 시간을 구하는 PPAS 전용 함수,

default가 with timezone)

•  select now()::timestamp : 16-JAN-13 15:33:39.627721 (timestamp로 명시적인 형 변환을 선언, default가 without timezone)

•  century, millennium 으로 오라클보다 다양한 기능 제공

•  Delaying Execution : pg_sleep(seconds) pg_sleep 함수는 정해진 시간만큼 현재 세션의 sleep 지정

PPAS 특성 – Data Type

Function Return Type   Example   Result age(timestamp, timestamp) interval age(timestamp ‘2001-0410’, timestamp ‘1957-06-13’) 43 years 9 mons 27 days

date_part(text, timestamp) double precision date_part(‘hour’, timestamp ‘2001-02-16 20:38:40’) 20

extract(field from timestamp) double precision extract(hour from timestamp '2001-02-16 20:38:40') 20

extract(field from interval) double precision extract(month from interval '2 years 3 months') 3

justify_days(interval) interval justify_days(interval '35 days') 1 mon 5 days

justify_interval(interval) interval justify_interval(interval '1 mon -1 hour') 29 days 23:00:00

current_date date

current_time time with time zone

current_timestamp timestamp with time zone

Page 28: Oracle to PPAS Migration Best Practice - rockPLACErockplace.co.kr/edm/201412/download/Session 2. O2PM Best... · 2014-12-05 · • Oracle Instant Client 11gR2 최신 ... $ expdp

© 2014 EDB All rights reserved. 28