illustrate
This description is based on ora2pg v21.0 version
Configuration file description
Configuration items | use | illustrate | Default value/format |
---|---|---|---|
IMPORT | Import configuration file | After saving the common configuration as a file, there is no need to edit the common configuration after importing other files. | - |
INPUT_FILE | Import file contents | Can only be used to import functions, stored procedures and package definitions | - |
ORACLE_HOME | Set up Oracle home directory | Environment variables have been configured before ora2pg is installed, and this is basically not needed. | - |
ORACLE_DSN | Oracle connection address | Service_name can be used instead of sid to realize service name connection. | dbi:Oracle:host=xx;sid=SIDNAME;port=xx |
ORACLE_USER | Oracle connection username | - | |
ORACLE_PWD | Oracle connection password | - | |
USER_GRANTS | Need to be set to 1 when using a non-DBA account | It is recommended to use a DBA account | 0 |
DEBUG | Output detailed logs of the migration process to the console | It is recommended to enable the configuration to 1 | 0 |
ORA_INITIAL_COMMAND | Execute instructions after connecting to oracle | For example, set session parameters or unlocking policy before reading data. This item can be configured multiple times | - |
EXPORT_SCHEMA | Export oracle schema | 0 | |
SCHEMA | Configure oracle schema or owner | It can be used when there is only a dba account and migrating other user data. | SCHEMA_NAME |
CREATE_SCHEMA | Define the sql statement that creates the schema at the beginning of the output file | 1 | |
COMPILE_SCHEMA | Force compilation of invalid functions, procedures, packages and user-defined types in the specified schema before migration | 1 | |
PG_SCHEMA | Configure the schema of postgresql | schema_name | |
POSTGIS_SCHEMA | Specify the schema used to search postgis | schema_name | |
SYSUSERS | Specify the system user name of oracle that is allowed to be used | All oracle system usernames are excluded by default | YOU, HR |
LOOK_FORWARD_FUNCTION | Search the configured schema for declarations of all functions, stored procedures, and packages, and then continue to export the structure | By default, ora2pg will only search for functions in the current schema | SCOTT,OE |
NO_FUNCTION_METADATA | Force ora2pg not to export function declarations | will cause ora2pg to replace the call when overriding the function. Do not enable this unless function export breaks | 0 |
NLS_NCHAR | Set the encoding of oracle database | AL32UTF8 | |
CLIENT_ENCODING | Set the encoding of the PostgreSQL database | UTF8 | |
TYPE | Configure the type to export | TABLE | |
DISABLE_COMMENT | Column comments are not exported | 0 | |
ALLOW | Configure the object name to be exported | TABLE_TEST | |
EXCLUDE | Configure object names to be excluded when exporting | OTHER_TABLES | |
VIEW_AS_TABLE | Export the specified view into a table | VIEW_NAME | |
NO_VIEW_ORDERING | Disable view sorting | By default, the views are sorted before exporting to prevent the views from calling each other and failing to write definitions after exporting. When there are many views, it will take a long time. | 0 |
GRANT_OBJECT | Specify the object type for which permissions are to be exported | The default is to export permissions for all objects | TABLE |
EXTERNAL_TO_FDW | Export external table as file_fdw table | If you do not want to export these tables, set this item to 0 | 1 |
TRUNCATE_TABLE | truncate table before COPY or INSERT | It takes effect only when no DELETE item is configured. | 0 |
DELETE | Delete some data before writing data, and configure data filtering conditions | TABLE_NAME[DELETE_WHERE_CLAUSE] | |
USE_TABLESPACE | Force export of table and index constraints based on configured table space name | It only takes effect when the table space name is not TEMP, USER, or SYSTEM. | 0 |
REORDERING_COLUMNS | Sort columns to minimize disk usage and accommodate more rows | 0 | |
WHERE | Migrate specified data and configure data filtering conditions | TABLE_NAME[WHERE_CLAUSE] | |
REPLACE_QUERY | Replace ora2pg's default statement for reading data when you have more complex reading requirements. | TABLENAME[SQL_QUERY] | |
CONTEXT_AS_TRGM | Force conversion of Text index to postgresql index using pg_trgm | pg_trgm will convert context index to FTS index and CTXCAT index | 0 |
FTS_INDEX_ONLY | Create a function based index to convert oracle text index | 1 | |
FTS_CONFIG | Force text search configuration | 如果未配置则默认检测所有的索引和pg_catelog.english | pg_catalog.french |
USE_UNACCENT | 0 | ||
USE_LOWER_UNACCENT | 0 | ||
SKIP | 在迁移过程关闭postgres的某些功能 | fkeys pkeys ukeys indexes checks | |
KEEP_PKEY_NAMES | 默认关闭。开启后导出的主键会与oracle库中同名 | 0 | |
PKEY_IN_CREATE | 开启后会将主键的定义写在表定义中,而不是通过alter table添加 | GreenPlum PostgreSQL建议开启该项 | 0 |
FKEY_ADD_UPDATE | 配置添加ON UPDATE CASCADE定义到外键定义语句中。Oracle不支持该语法,但Postgresql支持该语法 | never-外键定义与oracle中一致;delete是当外键定义了ON DELETE CASCADE时才会添加ON UPDATE CASCADE选项;always是强制所有选项添加ON UPDATE CASCADE | never delete always |
FKEY_DEFERRABLE | 将外键导出为可延迟的 | 默认是按原样导出的。如果外键未设置延迟则导出来也是不可延迟的,这可能导致一些文件,建议开启 | 0 |
DEFER_FKEY | 在数据导出过程延迟所有的外键,导入将在单个事务中完成 | 仅当外键是可延迟且未使用直接导入Postgresql时,该项才有效 | 0 |
DROP_FKEY | 导入数据前删除外键,导入完成后恢复外键 | 当外键是不可延迟的时候,可使用该项 | 0 |
DISABLE_SEQUENCE | 禁止序列更新在迁移过程中 | 0 | |
DISABLE_TRIGGERS | 迁移过程禁止触发器 ,在迁移过程中 | 0 | |
MODIFY_STRUCT | 只导出某些列的数据 | tables(fields separate by space or comma) | |
REPLACE_TABLES | 更换要迁移的表名 | ORIG_TB_NAME1:NEW_TB_NAME1 | |
REPLACE_COLS | 更换要迁移的列名 | TB_NAME(ORIG_COLNAME1:NEW_COLNAME1,ORIG_COLNAME2:NEW_COLNAME2) | |
PRESERVE_CASE | 保持迁移对象名的大小写 | 0 | |
INDEXES_SUFFIX | 给索引名添加后缀 | 当索引跟表同名时,建议配置该项 | _idx |
INDEXES_RENAMING | 按照“表名_列名“的格式给索引重命名 | 当多次使用相同索引名或相同表名的数据库,建议开启 | 0 |
USE_INDEX_OPCLASS | 强制使用运算符导出varchar2和char列上定义的索引 | 运算符类text_pattern_ops、varchar_pattern_ops和bpchar_pattern_ops支持相应类型上的B树索引。与默认运算符类的不同之处在于,这些值严格按字符进行比较,而不是根据特定于区域设置的排序规则进行比较。这使得这些运算符类适合于在数据库不使用标准“C”语言环境时涉及模式匹配表达式(如或POSIX正则表达式)的查询使用。如果启用值为1,则将强制Ora2Pg使用这些运算符导出varchar2()和char()列上定义的所有索引。如果将其设置为大于1的值,则只会更改字符限制大于或等于此值的列的索引。例如,将其设置为128,以便在类型为varchar2(N)的列上创建这类索引,其中N>=128 | 0 |
PREFIX_PARTITION | 通过父表导出分区表 | Oracle可能分区名相同,但父表名不同。PG是不允许的 | 0 |
PREFIX_SUB_PARTITION | 如果分区名是子分区名的一部分,禁用该项 | 1 | |
DISABLE_PARTITION | 开启后会将分区数据全部写到主表 | 默认值是将分区数据写入到PG专用分区表中 | 0 |
WITH_OID | 建表或将视图导出成表时,强制添加WITH (OIDS) | 0 | |
ORA_RESERVED_WORDS | 允许使用Oracle关键字转义列名 | audit,comment,references | |
USE_RESERVED_WORDS | 允许使用pg关键字,关键字将用双引号包起来 | 0 | |
DISABLE_UNLOGGED | 禁用UNLOGGED,将表导出为普通标 | 默认会将带有NOLOGGING属性的表导出为UNLOGGED表 | 0 |
PG_DSN | PG连接地址 | dbi:Pg:dbname=test_db;host=localhost;port=5432 | |
PG_USER | PG用户名 | ||
PG_PWD | PG密码 | ||
OUTPUT | 指定导出的数据文件名 | ||
OUTPUT_DIR | 指定导出的数据文件存放文件夹 | ||
FILE_PER_CONSTRAINT | 将约束保存在单独的文件中,该文件名格式为“CONSTRAINTS_OUTPUT” | 0 | |
FILE_PER_INDEX | 将索引保存在单独的文件中,该文件名格式为“INDEXES_OUTPUT” | 0 | |
FILE_PER_FKEYS | 将外键保存在单独的文件中,该文件名格式为“CONSTRAINT_output.sql” | 0 | |
FILE_PER_TABLE | 将表数据保存在单独的文件中,该文件名格式为“tablename_OUTPUT” | 0 | |
FILE_PER_FUNCTION | 将函数或存储过程保存在单独的文件中,该文件名格式为“funcname_OUTPUT” | 0 | |
BINMODE | 设置导出的文件的编码 | utf8 | |
STOP_ON_ERROR | 当发生错误时停止导出 | 1 | |
COPY_FREEZE | 使用COPY FREEZE 代替 COPY | 当-J或者ORACLE_COPIES为1时生效 | 0 |
CREATE_OR_REPLACE | 导出后使用CREATE OR REPLACE在函数的DDL中 | 1 | |
PG_INITIAL_COMMAND | 连接到postgresql后执行的初始指令 | 如读取数据前设置会话参数或者解锁策略。该项可配置多次 | |
DATA_TYPE | 指定oracle的postgresql的数据类型映射关系 | DATE:timestamp | |
PG_NUMERIC_TYPE | Oracle的NUMBER(p,s) 将转换为real和浮点类型。关闭后则转换为numeric(p,s) | 仅当对精度要求高的时候,关闭该项。因为numeric比real或double慢 | 1 |
PG_INTEGER_TYPE | Oracle的NUMBER§或NUMBER将转换为smallint 将转换为real和浮点类型 | 1 | |
DEFAULT_NUMERIC | 不带精度的NUMBER将转换为bigint | 需开启PG_INTEGER_TYPE选项 | bigint |
ENABLE_MICROSECOND | 如果不想从oracle的时间戳导出毫秒数据,将该项设为0 | 开启后时间格式为“YYYY-MM-DD HH24:MI:SS”,关闭后时间格式为“YYYY-MM-DD HH24:MI:SS.FF” | 1 |
REPLACE_AS_BOOLEAN | 将某些列的类型改为boolean | 比如当列为number或者char类型,且数据为1时 | TB_NAME1:COL_NAME1 |
BOOLEAN_VALUES | 当为配置的值时,这些可以被转义为pg的boolean类型数据 | yes:no y:n 1:0 true:false enabled:disabled | |
REPLACE_ZERO_DATE | 替换0000-00-00 00:00:00 | 默认是替换为null,但当列有非空约束时,需配置该项 | 1970-01-01 00:00:00 |
MODIFY_TYPE | 修改列的数据类型 | TABLE1:COL3:varchar | |
TO_NUMBER_CONVERSION | 将NUMBER强制转换为某类型 | numeric | |
GEN_USER_PWD | 开启后替换用户的默认密码 | 0 | |
FORCE_OWNER | 强制将对象的使用者设置为Oracle中使用者 | 默认是将连接账号设为OWNER | 0 |
FORCE_SECURITY_INVOKER | 覆盖函数的SECURITY DEFINER | 默认是使用Oracle中的SECURITY DEFINER | 0 |
DATA_LIMIT | 配置普通数据每次的抽取量 | 该值修改后需确保有足够内存 | 10000 |
BLOB_LIMIT | 配置BLOB数据的每次的抽取量 | 默认是抽取普通数据量的10% | 500 |
NOESCAPE | 默认转义所有非date或time类型的数据,可以设置1禁止转义 | 仅在COPY时生效 | 0 |
TRANSACTION | 更改数据导出时的事务隔离级别 | 可选值:readonly, readwrite, serializable and committed (read committed) | serializable |
STANDARD_CONFORMING_STRINGS | 开启后使用(E’…’) 转义数据 | 0 | |
LONGREADLEN | 配置数据导出的大小限制。当数据超过限制值时会报ORA-24345错误 | 1047552 | |
LONGTRUNCOK | 开启后可绕过ORA-24345错误 | 0 | |
NO_LOB_LOCATOR | 禁止该项将使用LOB locators代替BLOB和CLOB类型数据的全部文本信息 | 0 | |
LOB_CHUNK_SIZE | 设置LOB CHUNK的大小 | 512000 | |
XML_PRETTY | 开启后强制使用getStringVal()读取XML数据 | 0 | |
LOG_ON_ERROR | 开启后,数据导出失败后会继续导出 | 0 | |
TRIM_TYPE | 当数据转为为varchar或text时,对数据开头和结尾的空格进行修剪 | 可选值:LEADING(删除开头的空格)\TRAILING(删除结尾的空格)\BOTH(都删除空格) | BOTH |
TRIM_CHAR | 设置要移除的字段。默认为空格 | 与TRIM_TYPE字段配合使用 | - |
FUNCTION_CHECK | 对函数体进行检查 | 关闭该项,将会在导出时添加SET check_function_bodies = false; | |
NO_BLOB_EXPORT | 不导出blob数据 | 开启该项前需保证blob字段没有设置非空约束 | 0 |
DATA_EXPORT_ORDER | 指定数据导出的排序依据 | 默认值是name,即按照对象名进行排序后导致;可设置为size按照对象大小排序后导出 | name、size |
JOBS | 配置导出线程数 | 用于COPY、FUNCTION、PROCEDURE | 1 |
ORACLE_COPIES | 配置从oracle抽取数据的线程数 | 1 | |
PARALLEL_TABLES | 配置同时处理的表数量 | 1 | |
DEFAULT_PARALLELISM_DEGREE | 在oracle每次查询时添加/*+ PARALLEL(tbname, degree) */ | 0 | |
PARALLEL_MIN_ROWS | 当表的记录数小于该值时,则不会开启多线程模式 | 100000 | |
DEFINED_PK | 当表进行多线程读取时,通过SELECT * FROM TABLE WHERE MOD(COLUMN, $ORA_COPIES) = ?拆分数据读取,该项用于配置拆分依据。默认是使用主键 | TABLE:COLUMN TABLE:ROUND(COLUMN) | |
DROP_INDEXES | 迁移前删除索引,在数据导入后重建索引 | 0 | |
SYNCHRONOUS_COMMIT | 设置是否同步提交 | 默认关闭以提高写入速度。当需要数据直接加载到Postgresql需开启该项 | 0 |
EXPORT_INVALID | 是否导出不可用的函数、包、存储过程、用户自定义类型 | 0 | |
PLSQL_PGSQL | 是否启用PLSQL到PLPSQL的转换 | 1 | |
NULL_EQUAL_EMPTY | 指定null等于空字符串 | 0 | |
EMPTY_LOB_NULL | 将空的empty数据指定为null | 如果有大量的空lob数据列,建议开启,可以提升迁移速度 | 0 |
PACKAGE_AS_SCHEMA | 如果你只想将包导出成为一个简单的函数,需将该项设为0 | 关闭该项后,导出后的包命名从package_name.function_name() 变为package_name_function_name() | 1 |
REWRITE_OUTER_JOIN | 是否重写(+)语法 | 1 | |
FUNCTION_STABLE | 通过禁用配置指令,可以强制Ora2Pg将这些函数创建为VOLATILE | 1 | |
COMMENT_COMMIT_ROLLBACK | 是否注释COMMIT或ROLLBACK指令 | 0 | |
COMMENT_SAVEPOINT | 是否注释SAVEPOINT指令 | 0 | |
STRING_CONSTANT_REGEXP | 设置要临时替换的regexp列表,以不中断解析器regexp列表必须使用分号作为分隔符 | 默认只替换字符常量,即在两个单引号之间的值 | |
ALTERNATIVE_QUOTING_REGEXP | 支持字符串文本的替代引用机制(“Q”) | q’{(.*)}’ | |
AUTONOMOUS_TRANSACTION | 是否使用orafce函数 | 默认ora2pg会重写add_month(), add_year(), date_trunc() and to_char() 等函数 | 0 |
AUTONOMOUS_TRANSACTION | 允许使用dblink或pg_backgroud插件将自治事务转换为wrapper函数 | 如果想将其转为普通函数,需禁用该项 | 1 |
PG_VERSION | 指定PostgreSQL的版本 | 11 | |
BITMAP_AS_GIN | 是否使用gin索引 | 禁用后将使用btree索引。当pg版本大于9.4时该项有效 | 1 |
PG_BACKGROUND | 是否使用pg_backgroud替代dblink wrapper | 当pg版本大于9.5时有效 | 0 |
DBLINK_CONN | 配置dblink信息 | port=5432 dbname=pgdb host=localhost user=pguser password=pgpass | |
PG_SUPPORTS_SUBSTR | 指定是否支持substring() | redshift是不支持substring(),此时需将该项关闭 | 1 |
AUTODETECT_SPATIAL_TYPE | 是否检测空间列中使用的实际空间类型和维度 | 1 | |
CONVERT_SRID | 是否自动将srid转换为epsg | 1 | |
DEFAULT_SRID | 重写默认的epsg srid为4326 | 4326 |