205 Oracle To Postgres Migration
205 Oracle To Postgres Migration
205 Oracle To Postgres Migration
Migration
Considerations, Hurdles, and possible Solutions
Agenda
Schema Migration
Data Migration
Other Objects
DBA Migration
Tools
Ora2pg
Schema Migration
Schema Migration
Schema
Identifiers
Schema Migration
Tables
Partition clauses
Remove them
Columns
Schema Migration
Constraints
Indexes
Partitions
Schema Migration
Tablespace
Not really the same thing as Oracle, but serves the same purpose
CHAR, NCHAR
Convert to CHAR
CLOB, LONG
Note: TOAST
NUMBER
NUMERIC
Low performance
10
Date
DATE or TIMESTAMP
DATE arithmetic
DATE + integer
NLS_DATE_FORMAT
Data Migration
12
Data Migration
Data
13
Data Migration
Sequences
Extract sequence_name.nextval
Speeding up
14
15
General
General
Autonomous transactions
17
Triggers
:NEW, :OLD
18
Conditional triggers
Procedures
19
Functions
20
Packages
21
Local functions
Other Objects
23
Other Objects
Synonyms
Database Links
CONNECT BY
24
Other Objects
Materialized Views
Jonathan Gardner
http://tech.jonathangardner.net/wiki/PostgreSQL/Materialized_Views
http://www.pgcon.org/2008/schedule/events/69.en.html
Partitioning
25
Other Objects
Sequences
MAXVALUE 9999999999999999999999999
.nextval, .currval
nextval('sequence_name')
currval('sequence_name')
ORDER/NOORDER
PG doesn't have it
26
Other Objects
Sequences (continued)
NO{CACHE|MINVALUE|MAXVALUE|CYCLE}
27
Application Connectivity
(Drivers)
28
Application Connectivity
ODBC
JDBC
Works
.Net
Works
Npgsql
OCI
Oracle Forms
29
Application Migration
(Queries)
30
Application Migration
31
Application Migration
32
Application Migration
INTERSECT
Becomes EXCEPT
=> becomes :=
For example:
var = fn( c => 10, a => 'xyz', b => 2.5);
becomes
var = fn( c := 10, a := 'xyz', b := 2.5);
DUAL
Application Migration
ROWNUM
ROWID
Optimizer Hints
34
Application Migration
35
Builtin Functions
36
Builtin functions
NVL
Provided by Orafce
More flexible
DECODE
TO_CHAR()
Postgres has this, but not very robust; requires testing of queries.
37
Builtin functions
SUBSTR()
SYSDATE
Use current_timestamp
38
DBA Migration
(Database Architecture)
39
DBA Migration
No Rollback Segments
40
Porting Tools
41
Porting Tools
Orafce
DBMS_ALERT
DBMS_PIPE
UTL_FILE
DBMS_OUTPUT
DBMS_RANDOM
Date operations
DUAL table
42
Porting Tools
Ora2pg
43
Porting Tools
DBD::Oracle
Perl module
Developed by EnterpriseDB
44
Ora2pg
45
Ora2pg
Export Schema
Tables
PRIMARY KEY
UNIQUE
FOREIGN KEY
CHECK
Views
Sequences
Indexes
Export Privileges
GRANT
46
Ora2pg
Export partitions
Range
List
Platform independent
47
Ora2pg
48
Ora2pg
Steps to export
ORACLE_HOME
ORACLE_DSN
dbi:Oracle:host=oradb_host.mydom.dom;sid=TEST
ORACLE_PWD
TRANSACTION
49
Ora2pg
TYPE : What kind of export you want; can specify only one.
DATA, COPY
PARTITION : Work-in-progress
50
Ora2pg
not these
WHERE
WHERE
my_table[ ID=200 ]
WHERE
Modify structure
MODIFY_STRUCT
MODIFY_STRUCT
T_TEST1(id,dossier) T_TEST2(id,fichier)
REPLACE_COLS
REPLACE_COLS
T_TEST(dico
51
: dictionary,dossier : folder)
Ora2pg
52
Ora2pg
PG_DSN
dbi:Pg:dbname=pgdb;host=localhost;port=5432
PG_USER
PG_PWD
53
Ora2pg
SKIP
KEEP_PKEY_NAMES
DEFER_FKEY
FKEY_DEFERRABLE
indices,checks
DROP_FKEY
Drop Foreign Keys before data load, and recreate them later
54
Ora2pg
DROP_INDEXES
DISABLE_TABLE_TRIGGERS: 0/USER/ALL
DISABLE_SEQUENCE
DATA_TYPE
DATA_TYPE
DATE:timestamp,LONG:text,LONG RAW:text
55
Ora2pg
CASE_SENSITIVE
ORA_RESERVED_WORDS
56
Ora2pg
Encoding conversion
NLS_LANG
AMERICAN_AMERICA.UTF8
BINMODE
BINMODE
utf8
CLIENT_ENCODING
CLIENT_ENCODING LATIN9
57
Thank You
58