mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-27 08:39:28 +08:00
2e2d17ed51
Oracle database to PostgreSQL. It currently dump the database schema (tables, views, sequences, indexes, grants), with primary, unique and foreign keys into PostgreSQL syntax without editing the SQL code generated. You can dump only a particular schema from the Oracle database. Functions, procedures and triggers with SQL or PLSQL code generated must be reviewed to match the PostgreSQL syntax. Some usefull recommandation on porting Oracle to PostgreSQL can be found at http://techdocs.postgresql.org/ under the "Converting from other Databases to PostgreSQL" Oracle part. I just notice one thing more is that the trunc() function in Oracle is the same for number or date so be carefull when porting to PostgreSQL to use trunc() for number and date_trunc() for date. I will add more precision in type NUMBER conversion based on length to match as closest as possible all rich PostgreSQL numerics type. But it seems not to be urgent as it seems that Oracle DBAs only create number with length 22 (default) Space seems not to be their problem... Gilles DAROLD
56 lines
1.9 KiB
Perl
Executable File
56 lines
1.9 KiB
Perl
Executable File
#!/usr/bin/perl
|
|
#------------------------------------------------------------------------------
|
|
# Project : Oracle2Postgresql
|
|
# Name : ora2pg.pl
|
|
# Language : 5.006 built for i686-linux
|
|
# OS : linux RedHat 6.2 kernel 2.2.14-5
|
|
# Author : Gilles Darold, gilles@darold.net
|
|
# Copyright: Copyright (c) 2000 : Gilles Darold - All rights reserved -
|
|
# Function : Script used to convert Oracle Database schema to PostgreSQL
|
|
#------------------------------------------------------------------------------
|
|
# Version : 1.0
|
|
#------------------------------------------------------------------------------
|
|
|
|
BEGIN {
|
|
$ENV{ORACLE_HOME} = '/usr/local/oracle/oracle816';
|
|
}
|
|
|
|
use strict;
|
|
|
|
use Ora2Pg;
|
|
|
|
# Initialyze the database connection
|
|
my $dbsrc = 'dbi:Oracle:host=test.mydomain.com;sid=TEST;port=1521';
|
|
my $dbuser = 'system';
|
|
my $dbpwd = 'manager';
|
|
|
|
# Create an instance of the XSD::DBISchema perl module
|
|
my $schema = new Ora2Pg (
|
|
datasource => $dbsrc, # Database DBD datasource
|
|
user => $dbuser, # Database user
|
|
password => $dbpwd, # Database password
|
|
debug => 1, # Verbose mode
|
|
schema => 'APPS', # Extract only APPS schema
|
|
type => 'TABLE', # Extract table
|
|
# type => 'VIEW', # Extract views
|
|
# type => 'GRANT', # Extract privileges
|
|
# type => 'SEQUENCE', # Extract sequences
|
|
# type => 'TRIGGER', # Extract triggers
|
|
# type => 'FUNCTION', # Extract functions
|
|
# type => 'PROCEDURE', # Extract procedures
|
|
# tables => [('FND_USER_PREFERENCES')], # unique index + users
|
|
# tables => [('CUSTOMER_DATA')], # Unique and primary key
|
|
# tables => [('TX_DATA')], # simple indexes
|
|
# tables => [('NDW_BROWSER_ATTRIBUTES')], # view
|
|
# tables => [('TRIP_DATA')], # Foreign key
|
|
# showtableid => 1, # Display only table indice during extraction
|
|
# min => 1, # Extract begin at indice 3
|
|
# max => 10 # Extract ended at indice 5
|
|
);
|
|
|
|
# Create the POSTGRESQL representation of all objects in the database
|
|
$schema->export_schema("output.sql");
|
|
|
|
exit(0);
|
|
|