By default conversion to Postgres Pro format is written to file output.sql.
psql mydb < output.sql
This command will import content of the file output.sql into Postgres Pro mydb database.
DATA_LIMITWhen you are performing
INSERT/COPYexport, ora2pgpro proceeds by chunks ofDATA_LIMITtuples for speed improvement. Tuples are stored in memory before being written to disk, so if you want speed and have enough system resources you can raise this limit to an higher value for example: 100000 or 1000000. A value of 0 means that the chunk will be set to the default: 10000.BLOB_LIMITWhen ora2pgpro detects a table with some BLOB, it will automatically reduce the value of this directive by dividing it by 10 until its value is below 1000. You can control this value by setting
BLOB_LIMIT. Exporting BLOB use lot of resources, setting it to a too high value can produce OOM.OUTPUTThe ora2pgpro output filename can be changed with this directive. Default value is
output.sql. If you set the file name with extension.gzor.bz2, the output will be automatically compressed. This requires that theCompress::ZlibPerl module is installed if the filename extension is.gzand that the bzip2 system command is installed for the.bz2extension.OUTPUT_DIRYou can define a base directory where the file will be written. The directory must exist.
BZIP2This directive allows you to specify the full path to the bzip2 program if it can not be found in the
PATHenvironment variable.FILE_PER_CONSTRAINTAllow object constraints to be saved in a separate file during schema export. The file will be named
CONSTRAINTS_OUTPUT, whereOUTPUTis the value of the corresponding configuration directive. You can use.gzor.bz2extension to enable compression. Default is to save all data in theOUTPUTfile. This directive is usable only withTABLEexport type.The constraints can be imported quickly into Postgres Pro using the
LOADexport type to parallelize their creation over multiple (-jorJOBS) connections.FILE_PER_INDEXAllow indexes to be saved in a separate file during schema export. The file will be named
INDEXES_OUTPUT, whereOUTPUTis the value of the corresponding configuration directive. You can use.gzor.bz2file extension to enable compression. Default is to save all data in theOUTPUTfile. This directive is usable only withTABLEANDTABLESPACEexport type. With theTABLESPACEexport, it is used to write ALTER INDEX ... TABLESPACE ... into a separate file namedTBSP_INDEXES_OUTPUTthat can be loaded at end of the migration after the indexes creation to move the indexes.The indexes can be imported quickly into Postgres Pro using the
LOADexport type to parallelize their creation over multiple (-jorJOBS) connections.FILE_PER_FKEYSAllow foreign key declaration to be saved in a separate file during schema export. By default foreign keys are exported into the main output file or in the
CONSTRAINT_output.sqlfile. When enabled, foreign keys will be exported into a file namedFKEYS_output.sql.FILE_PER_TABLEAllow data export to be saved in one file per table/view. The files will be named as
tablename_OUTPUT, whereOUTPUTis the value of the corresponding configuration directive. You can still use.gzor.bz2extension in theOUTPUTdirective to enable compression. Default 0 will save all data in one file, set it to 1 to enable this feature. This is usable only duringINSERTorCOPYexport type.FILE_PER_FUNCTIONAllow functions, procedures and triggers to be saved in one file per object. The files will be named as
objectname_OUTPUT, whereOUTPUTis the value of the corresponding configuration directive. You can still use.gzor.bz2extension in theOUTPUTdirective to enable compression. Default 0 will save all in one single file, set it to 1 to enable this feature. This is usable only during the corresponding export type, the package body export has a special behavior.When export type is
PACKAGE, and you enabled this directive, ora2pgpro will create a directory per package, named with the lower-case name of the package, and will create one file per function/procedure into that directory. If the configuration directive is not enabled, it will create one file per package aspackagename_OUTPUT, whereOUTPUTis the value of the corresponding directive.TRUNCATE_TABLEIf this directive is set to 1, a TRUNCATE TABLE instruction will be added before loading data. This is usable only during
INSERTorCOPYexport type.When activated, the instruction will be added only if there is no global DELETE clause or not one specific to the current table (see below).
DELETESupport for include a DELETE FROM ... WHERE clause filter before importing data and perform a deletion of some lines instead of truncating tables. Value is constructed as follows:
TABLE_NAME[DELETE_WHERE_CLAUSE], or if you have only oneWHEREclause for all tables just put theDELETEclause as a single value. Both are possible too. Here are some examples:DELETE 1=1 # Apply to all tables and delete all tuples DELETE TABLE_TEST[ID1='001'] # Apply only on table TABLE_TEST DELETE TABLE_TEST[ID1='001' OR ID1='002] DATE_CREATE > '2001-01-01' TABLE_INFO[NAME='test']
The last applies two different delete where clause on tables
TABLE_TESTandTABLE_INFOand a genericDELETEclause onDATE_CREATEto all other tables. IfTRUNCATE_TABLEis enabled, it will be applied to all tables not covered by theDELETEdefinition. TheseDELETEclauses might be useful with regular updates.STOP_ON_ERRORSet this parameter to 0 to not include the call to \set ON_ERROR_STOP ON in all SQL scripts generated by ora2pgpro. By default this order is always present so that the script will immediately abort when an error is encountered.
COPY_FREEZEEnable this directive to use
COPY FREEZEinstead of a simpleCOPYto export data with rows already frozen. This is intended as a performance option for initial data loading. Rows will be frozen only if the table being loaded has been created or truncated in the current sub-transaction. This will only work with export to file and when-JorORACLE_COPIESis not set or defaults to 1. It can be used with direct import into Postgres Pro under the same condition, but-jorJOBSmust also be unset or default to 1.CREATE_OR_REPLACEBy default ora2pgpro uses CREATE OR REPLACE in functions and views DDL, if you need not to override existing functions or views disable this configuration directive, DDL will not include OR REPLACE.
DROP_IF_EXISTSTo add a DROP
OBJECTIF EXISTS before creating the object, enable this directive. Can be useful in an iterative work. Default is disabled.EXPORT_GTTPostgres Pro does not support Global Temporary Table natively but you can use the pgtt extension to emulate this behavior. Enable this directive to export global temporary table.
NO_HEADEREnabling this directive will prevent ora2pgpro to print its header into output files. Only the translated code will be written.
PSQL_RELATIVE_PATHBy default ora2pgpro use
\ipsql command to execute generated SQL files if you want to use a relative path following the script execution file enabling this option will use\ir. See psql help for more information.DATA_VALIDATION_ROWSNumber of rows that must be retrieved on both sides for data validation. Default it to compare the 10000 first rows. A value of 0 means to compare all rows.
DATA_VALIDATION_ORDERINGOrder of rows between both sides is different once the data have been modified. In this case data must be ordered using a primary key or a unique index, that means that a table without such objects can not be compared. If the validation is done just after the data migration without any data modification, the validation can be done on all tables without any ordering.
DATA_VALIDATION_ERRORStop validating data from a table after a certain amount of row mismatch. Default is to stop after 10 rows validation errors.
TRANSFORM_VALUEUse this directive to specify which transformation should be applied to a column when exporting data. Value must be a semicolon-separated list of the following:
TABLE[COLUMN_NAME,
code in SELECT target list]For example, to replace string “Oracle” by “PostgreSQL” in a varchar2 column, use the following:
TRANSFORM_VALUE ERROR_LOG_SAMPLE[DBMS_TYPE:regexp_replace("DBMS_TYPE",'Oracle','PostgreSQL')]To replace all Oracle char(0) in a string with a space character:
TRANSFORM_VALUE CLOB_TABLE[CHARDATA:translate("CHARDATA", chr(0), ' ')]The expression will be applied in the SQL statement used to extract data from the source database.
When using ora2pgpro the export type INSERT or COPY to dump data to the file and that FILE_PER_TABLE is enabled, you will be warned that ora2pgpro will not export data again if the file already exists. This is to prevent downloading twice the table with a huge amount of data. To force the download of data from these tables, you have to remove the existing output file first.
If you want to import data on the fly to the Postgres Pro database, you have three configuration directives to set the Postgres Pro database connection. This is only possible with COPY or INSERT export type as for the database schema there is no real interest to do that.
PG_DSNUse this directive to set the Postgres Pro data source namespace using
DBD::PgPerl module as follows:dbi:Pg:dbname=pgdb;host=localhost;port=5432
It will connect to the database
pgdbonlocalhostat TCP port 5432.Note that this directive is only used for data export, other export needs to be imported manually through the use of psql or any other Postgres Pro client.
To use SSL-encrypted connection, you must add
sslmode=requireto the connection string like this:dbi:Pg:dbname=pgdb;host=localhost;port=5432;sslmode=require
PG_USER,PG_PWDThese two directives are used to set the login user and password. If you do not supply a credential with
PG_PWD, and you have installed theTerm::ReadKeyPerl module, ora2pgpro will ask for the password interactively. IfPG_USERis not set, it will be asked interactively too.SYNCHRONOUS_COMMITSpecifies whether the transaction commit will wait for WAL records to be written to disk before the command returns a success indication to the client. This is the equivalent to setting
synchronous_commitdirective of thepostgresql.conffile. This is only used when you load data directly to Postgres Pro, the default is off to disable the synchronous commit to gain speed at writing data.PG_INITIAL_COMMANDThis directive can be used to send an initial command to Postgres Pro, just after the connection, for example, to set some session parameters. This directive can be used multiple times.