日本語マニュアル
7.8 Example
8.2.3 Error Creating Constraint CONS_NAME_FK
•
•
This guide uses the term Postgres to refer to either an installation of Advanced Server or PostgreSQL.
This guide uses the term Stack Builder to refer to either StackBuilder Plus (distributed with Advanced Server) or Stack Builder (distributed with the PostgreSQL one-click installer from EnterpriseDB).
•
The overall data migration time from Oracle to Advanced Server improved substantially while fixing the fetchSize option related issue. Initial testing in our labs showed a percentage improvement of around 45% for data migration. The following commands were used for testing:
•
Earlier this release, TEXT, TINYTEXT, MEDIUMTEXT, and LONGTEXT datatypes were mapped to Advanced Server’s CLOB data type. As these data types existed in Advanced Server, the data types are now mapped with the right family. As a positive effect of this, the data migration time for the tables containing any of these data types have improved.

In the following descriptions a term refers to any word or group of words that are language keywords, user-supplied values, literals, etc. A term’s exact meaning depends upon the context in which it is used.
•
Italic font introduces a new term, typically, in the sentence that defines it for the first time.
•
Fixed-width (mono-spaced) font is used for terms that must be given literally such as SQL commands, specific table and column names used in the examples, programming language keywords, etc. For example, SELECT * FROM emp;
•
Italic fixed-width font is used for terms for which the user must substitute values in actual usage. For example, DELETE FROM table_name;
•
Square brackets [ ] denote that one or none of the enclosed term(s) may be substituted. For example, [ a | b ], means choose one of “a” or “b” or neither of the two.
•
Braces {} denote that exactly one of the enclosed alternatives must be specified. For example, { a | b }, means exactly one of “a” or “b” must be specified.
•
Ellipses ... denote that the proceeding term may be repeated. For example, [ a | b ] ... means that you may have the sequence, “b a a b a”.

Note: EnterpriseDB does not support the use of Migration Toolkit with Oracle Real Application Clusters (RAC) and Oracle Exadata; the aforementioned Oracle products have not been evaluated nor certified with this EnterpriseDB product.
2.
Identify potential migration problems. If it is an Oracle-to-Advanced Server migration, consult the Database Compatibility for Oracle® Developer's Guide for complete details about the compatibility features supported in Advanced Server. Consider using EnterpriseDB's migration assessment service to assist in this review.
•
If your data has BLOB or CLOB data, use the dblink_ora style database links instead of the Oracle style database links.
•
Use Dynatune to dynamically adjust database configuration resources.
•
Use Optimizer Hints to direct the query path.
•
Use the ANALYZE command to retrieve database statistics.
The EDB Postgres Advanced Server Guide and Database Compatibility for Oracle Developer's Guide (both available through the EnterpriseDB website) offer information about the performance tuning tools available with Advanced Server.

Most Linux and Windows systems include graphical tools that allow you to create and edit ODBC data sources. After installing ODBC, check the Administrative Tools menu for a link to the ODBC Data Source Administrator. Click the Add button to start the Create New Data Source wizard; complete the dialogs to define the new target data source.
The application will contain a call to SQLConnect (or possibly SQLDriverConnect); edit the invocation to change the data source name. In the following example, the data source is named "OracleDSN":
•
Use the -safeMode option to commit each row as it is migrated.
•
Use the -fastCopy option to bypass WAL logging to optimize migration.
•
Use the -batchSize option to control the batch size of bulk inserts.
•
Use the -cpBatchSize option to specify the batch size used with the COPY command.
•
Use the -lobBatchSize option to specify the batch size used for large object data types.
•
Use the -filterProp option to migrate only those rows that meet a user-defined condition.
•
Use the -customColTypeMapping option to change the data type of selected columns.
•
Use the -dropSchema option to drop the existing schema and create a new schema prior to migration.
•
On Advanced Server, use the -allDBLinks option to migrate all Oracle database links.
•
On Advanced Server, use the -copyViaDBLinkOra option to enable the dblink_ora module.
1.
Edit the toolkit.properties file to specify the source and target database.
•
•
For detailed information about defining toolkit.properties entries, please refer to Section 5, Building the toolkit.properties File.
Migration Toolkit can migrate immediately and directly into a Postgres database (online migration), or you can also choose to generate scripts to use at a later time to recreate object definitions in a Postgres database (offline migration).
By default, Migration Toolkit creates objects directly into a Postgres database; in contrast, include the -offlineMigration option to generate SQL scripts you can use at a later time to reproduce the migrated objects or data in a new database. You can alter migrated objects by customizing the migration scripts generated by Migration Toolkit before you execute them. With the -offlineMigration option, you can schedule the actual migration at a time that best suits your system load.
For more information about the -offlineMigration option, see Section 7.1, Offline Migration.
You can use an RPM package or Stack Builder to install Migration Toolkit. Stack Builder is distributed with both Advanced Server and the PostgreSQL one-click installer, available from EnterpriseDB. For more information about performing an installation with Stack Builder, see Section 4.2
Before installing Migration Toolkit, you must first install Java (version 1.7.0 or later). Free downloads of Java installers and installation instructions are available at:
You can use an RPM package to install Migration Toolkit on a 64-bit Linux host. For information about configuring yum to install packages from the enterprisedb-tools repository, please see the EDB Postgres Advanced Server Installation Guide, available at:
After using an RPM package to install Migration Toolkit, you must configure the Installation. Please note that you must install a Java environment before invoking Migration Toolkit.
By default, the pg_hba.conf file for the RPM installer enforces IDENT authentication for remote clients. Before invoking Migration Toolkit, you must either modify the pg_hba.conf file, changing the authentication method to a form other than IDENT (and restarting the server), or perform the following steps to ensure that an IDENT server is accessible:
1.
Confirm that an identd server is installed and running. For example, you can use the yum package manager to install an identd server by invoking the command:
The command should create a file named /etc/xinetd.d/auth that contains:
Note: if the file includes a -E argument at the end of server_args, please erase the -E.
Then, to start the identd server, invoke the commands:
2.
Open the pg_ident.conf file and create a user mapping:
The name specified in the map_name column is a user-defined name that will identify the mapping in the pg_hba.conf file.
The name specified in the system_username column is enterprisedb.
The name specified in the postgres_username column is enterprisedb.
3.
Open the pg_hba.conf file and modify the IDENT entries.
On an IPv4 host:

host all all 127.0.0.0/0 ident map=edbas
On an IPv6 host:

host all all ::1/128 ident map=edbas
Please Note: This guide uses the term Stack Builder to refer to either StackBuilder Plus (distributed with Advanced Server) or Stack Builder (distributed with the PostgreSQL one-click installer from EnterpriseDB).
The Java executable must be in your search path (%PATH% on Windows, $PATH on Linux/Unix). Use the following commands to set the search path (substituting the name of the directory that holds the Java executable for javadir):
SET PATH=javadir;%PATH%
PATH=javadir:$PATH
To launch StackBuilder Plus from an existing Advanced Server installation, navigate through the Start (or Applications) menu to the EDB Postgres menu; open the EDB Add-ons menu, and select the StackBuilder Plus menu option.
Launching Stack Builder from PostgreSQL
To launch Stack Builder from a PostgreSQL installation, navigate through the Start (or Applications) menu to the PostgreSQL menu, and select the Application StackBuilder Plus menu option.
Use the drop-down listbox to select the target server installation from the list of available servers. If your network requires you to use a proxy server to access the Internet, use the Proxy servers button to open the Proxy servers dialog and specify a proxy server; if you do not need to use a proxy server, click Next to open the application selection window.
If you are using StackBuilder Plus to add Migration Toolkit to your Advanced Server installation, expand the Add-ons, tools and utilities node of the tree control, and check the box next to EnterpriseDB Migration Toolkit (as shown in Figure 4.3). Click Next to continue.
If you are using Stack Builder to add Migration Toolkit to your PostgreSQL installation, expand the EnterpriseDB Tools node of the tree control (located under the Registration-required and trial products node), and check the box next to Migration Toolkit. Click Next to continue.
After specifying a configuration mode, click Next to continue to the Password window (shown in Figure 3.7).
Advanced Server uses the password specified on the Password window for the database superuser. The specified password must conform to any security policies existing on the Advanced Server host.
Confirm that Migration Toolkit is included in the Selected Packages list and that the Download directory field contains an acceptable download location (as shown in Figure 4.5). Click Next to start the Migration Toolkit download (see Figure 4.6).
C:\Users\susan\AppData\Local\Temp\vmware-susan\VMwareDnD\58fbe83a\thirteen.png
By default, Migration Toolkit will be installed in the mtk directory; accept the default installation directory as displayed (see Figure 4.12), or modify the directory, and click Next to continue.
The installation wizard confirms that the Setup program is ready to install Migration Toolkit (as shown in Figure 4.13); click Next to start the installation.
When Stack Builder finalizes installation of the last selected component, it displays the Installation Completed window (shown in Figure 4.15). Click Finish to close Stack Builder.
After downloading the source-specific driver, move the driver file into the JAVA_HOME/jre/lib/ext directory.
Migration Toolkit uses the configuration and connection information stored in the toolkit.properties file during the migration process to identify and connect to the source and target databases. On Linux, the toolkit.properties file is located in:
A sample toolkit.properties file is shown in Figure 5.1.
C:\Users\susan\AppData\Local\Temp\VMwareDnD\871aca59\Screen shot 2015-03-01 at 12.55.18 PM.png
Figure 5.1 - A typical toolkit.properties file.
Before executing Migration Toolkit commands, modify the toolkit.properties file with the editor of your choice. Update the file to include the following information:
•
SRC_DB_URL specifies how Migration Toolkit should connect to the source database. See the section corresponding to your source database for details about forming the URL.
•
SRC_DB_USER specifies a user name (with sufficient privileges) in the source database.
•
SRC_DB_PASSWORD specifies the password of the source database user.
•
TARGET_DB_URL specifies the JDBC URL of the target database.
•
TARGET_DB_USER specifies the name of a privileged target database user.
•
TARGET_DB_PASSWORD specifies the password of the target database user.
•
•
•
Migration Toolkit reads connection specifications for the source and the target database from the toolkit.properties file. Connection information for each must include:
edb
If you are using Advanced Server, specify edb for the sub-protocol value.
{TARGET_DB_USER|SRC_DB_USER} must specify a user with privileges to CREATE each type of object migrated. If migrating data into a table, the specified user may also require INSERT, TRUNCATE and REFERENCES privileges for each target table.
{TARGET_DB_PASSWORD|SRC_DB_PASSWORD} is set to the password of the privileged Advanced Server user.
•
•
Migration Toolkit reads connection specifications for the source and the target database from the toolkit.properties file. Connection information for each must include:
If you are using PostgreSQL, specify postgresql for the sub-protocol value.
{SRC_DB_USER|TARGET_DB_USER}must specify a user with privileges to CREATE each type of object migrated. If migrating data into a table, the specified user may also require INSERT, TRUNCATE and REFERENCES privileges for each target table.
{SRC_DB_PASSWORD|TARGET_DB_PASSWORD}is set to the password of the privileged PostgreSQL user.
When migrating from an Oracle database, SRC_DB_URL should contain a JDBC URL, specified in one of two forms. The first form is:
jdbc:oracle:thin:@host_name:port:database_id
jdbc:oracle:thin:@//host_name:port/{database_id|service_name}
SRC_DB_USER should specify the name of a privileged Oracle user. Note: The Oracle user should have DBA privilege to migrate objects from Oracle to Advanced Server. The DBA privilege can be granted to the Oracle user with the Oracle GRANT DBA TO user command to ensure all of the desired database objects are migrated.
SRC_DB_PASSWORD must contain the password of the specified user.
When migrating from MySQL, SRC_DB_URL takes the form of a JDBC URL. For example:
jdbc:mysql://host_name[:port]/database_id
[port]
SRC_DB_USER should specify the name of a privileged MySQL user.
SRC_DB_PASSWORD must contain the password of the specified user.
When migrating from Sybase, SRC_DB_URL takes the form of a JTDS URL. For example:
jdbc:jtds:sybase://host_name[:port]/database_id
SRC_DB_USER should specify the name of a privileged Sybase user.
SRC_DB_PASSWORD must contain the password of the specified user.
•
•
•
Migration Toolkit reads connection specifications for the source database from the toolkit.properties file. The connection information must include:
If you are connecting to a SQL Server database, SRC_DB_URL takes the form of a JTDS URL. For example:
jdbc:jtds:sqlserver://server[:port]/database_id
SRC_DB_USER should specify the name of a privileged SQL Server user.
SRC_DB_PASSWORD must contain the password of the specified user.
The Migration Toolkit executable is named runMTK.sh on Linux systems and runMTK.bat on Windows systems. On a Linux system, the executable is located in:
Note: If the following error appears upon invoking the Migration Toolkit, check the file permissions of the toolkit.properties file.
The operating system user account running the Migration Toolkit must be the owner of the toolkit.properties file with a minimum of read permission on the file. In addition, there must be no permissions of any kind for group and other users. The following is an example of the recommended file permissions where user enterprisedb is running the Migration Toolkit.
However, the Migration Toolkit does not support importation of NULL character values (embedded binary zeros 0x00) with the JDBC connection protocol. If you are importing data that includes the NULL character, use the -replaceNullChar option to replace the NULL character with a single, non-NULL, replacement character.
$ ./runMTK.sh schema_name
> .\runMTK.bat schema_name
schema_name is the name of the schema within the source database (specified in the toolkit.properties file) that you wish to migrate. You must include at least one schema_name.
Note: When the default database user of a migrated schema is automatically migrated, the custom profile of the default database user is also migrated if such a custom profile exists. A custom profile is a user-created profile. For example, custom profiles exclude Oracle profiles DEFAULT and MONITORING_PROFILE.
$ ./runMTK.sh schema_name1,schema_name2,schema_name3
> .\runMTK.bat schema_name1,schema_name2,schema_name3
$ ./runMTK.sh -sourcedbtype db_type -targetdbtype target_type [options, …] schema_name;
-sourcedbtype source_type
source_type specifies the server type of the source database. source_type is case-insensitive. By default, source_type is oracle. source_type may be one of the following values:
oracle (the default value)
postgres or postgresql
target_type specifies the server type of the target database. target_type is case-insensitive. By default, target_type is enterprisedb. target_type may be one of the following values:
postgres or postgresql
schema_name is the name of the schema within the source database (specified in the toolkit.properties file) that you wish to migrate. You must include at least one schema_name.
The following example migrates a schema (table definitions and table content) named HR from a MySQL database on a Linux system to an Advanced Server host. Note that the command includes the ‑sourcedbtype and targetdbtype options:
> .\runMTK.bat -sourcedbtype mysql -targetdbtype enterprisedb HR
If you specify the -offlineMigration option in the command line, Migration Toolkit performs an offline migration. During an offline migration, Migration Toolkit reads the definition of each selected object and creates an SQL script that, when executed at a later time, replicates each object in Postgres.
To perform an offline migration of both schema and data, specify the ‑offlineMigration keyword, followed by the schema name:
$ ./runMTK.sh -offlineMigration file_dest schema_name
To perform an offline migration of schema objects only (creating empty tables), specify the ‑schemaOnly keyword in addition to the ‑offlineMigration keyword when invoking Migration Toolkit:
To perform an offline migration of data only (omitting any schema object definitions), specify the ‑dataOnly keyword and the ‑offlineMigration keyword when invoking Migration Toolkit
By default, data is written in COPY format; to write the data in a plain SQL format, include the ‑safeMode keyword:
$ ./runMTK.sh -offlineMigration -dataOnly -safeMode schema_name
Please note: the -singleDataFile option is available only when migrating data in a plain SQL format; you must include the -safeMode keyword if you include the ‑singleDataFile option.
You can use the edb-psql command line (on Advanced Server) or psql command line (on PostgreSQL) to execute the scripts generated during an offline migration. The following example describes restoring a schema (named hr) into a new database (named acctg) stored in Advanced Server.
1.
Use the createdb utility to create the acctg database, into which we will restore the migrated database objects:
3.
Use the \i meta-command to invoke the migration script that creates the object definitions:
4.
If the -offlineMigration command included the ‑singleDataFile keyword , the mtk_hr_data.sql script will contain the commands required to recreate all of the objects in the new target database. Populate the database with the command:
By default, Migration Toolkit assumes the source database to be Oracle and the target database to be Advanced Server; include the ‑sourcedbtype and -targetdbtype keywords to specify a non-default source or target database.
-sourcedbtype source_type
The -sourcedbtype option specifies the source database type. source_type may be one of the following values: mysql, oracle, sqlserver, sybase, postgresql or enterprisedb. source_type is case-insensitive. By default, source_type is oracle.
-targetdbtype target_type
The -targetdbtype option specifies the target database type. target_type may be one of the following values: enterprisedb, postgres, or postgresql. target_type is case-insensitive. By default, target_type is enterprisedb.
This option copies the table data only. When used with the -tables option, Migration Toolkit will only import data for the selected tables (see usage details below). This option cannot be used with -schemaOnly option.
When set to true, Migration Toolkit drops the existing schema (and any objects within that schema) and creates a new schema. (By default, -dropSchema is false).
-targetSchema schema_name
Use the -targetSchema option to specify the name of the migrated schema. If you are migrating multiple schemas, specify a name for each schema in a comma-separated list with no intervening space characters. If the command line does not include the -targetSchema option, the name of the new schema will be the same as the name of the source schema.
You cannot specify information-schema, dbo, sys or pg_catalog as target schema names. These schema names are reserved for meta-data storage in Advanced Server.
-tables table_list
Import the selected tables from the source schema. table_list is a comma-separated list (with no intervening space characters) of table names (e.g., -tables emp,dept,acctg).
By default, Migration Toolkit does not implement migration of check constraints and default clauses from a Sybase database. Include the ‑ignoreCheckConstFilter parameter when specifying the -constraints parameter to migrate constraints and default clauses from a Sybase database.
This option is valid only when importing an entire schema or when the -allTables or -tables table_list options are specified.
Import the table indexes. This option is valid when importing an entire schema or when the -allTables or -tables table_list option is specified.
Import the views from the source schema. Please note that this option will migrate both dynamic and materialized views from the source. (Oracle and Postgres materialized views are supported.)
-views view_list
Import the specified materialized or dynamic views from the source schema. (Oracle and Postgres materialized views are supported.) view_list is a comma-separated list (with no intervening space characters) of view names (e.g., -views all_emp,mgmt_list,acct_list).
-sequences sequence_list
Import the selected sequences from the source schema. sequence_list is a comma-separated list (with no intervening space characters) of sequence names.
-procs procedures_list
Import the selected stored procedures from the source schema. procedures_list is a comma-separated list (with no intervening space characters) of procedure names.
-funcs function_list
Import the selected functions from the source schema. function_list is a comma-separated list (with no intervening space characters) of function names.
When false, disables validation of the function body during function creation (to avoid errors if the function contains forward references). The default value is true.
-packages package_list
Import the selected packages from the source schema. package_list is a comma-separated list (with no intervening space characters) of package names.
-allDomains
Import all queues from the source schema. These are queues created and managed by the DBMS_AQ and DBMS_AQADM built-in packages. When Oracle is the source database, the -objectTypes option must also be specified. When Advanced Server is the source database, the -allDomains and -allTables options must also be specified. (Oracle and Advanced Server queues are supported.)
-queues queue_list
Import the selected queues from the source schema. queue_list is a comma-separated list (with no intervening space characters) of queue names. These are queues created and managed by the DBMS_AQ and DBMS_AQADM built-in packages. When Oracle is the source database, the -objectTypes option must also be specified. When Advanced Server is the source database, the -allDomains and -allTables options must also be specified. (Oracle and Advanced Server queues are supported.)
-allRules
Use the -loaderCount option to specify the number of parallel threads that Migration Toolkit should use when importing data. This option is particularly useful if the source database contains a large volume of data, and the Postgres host (that is running Migration Toolkit) has high-end CPU and RAM resources. While value may be any non-zero, positive number, we recommend that value should not exceed the number of CPU cores; a dual core CPU should have an optimal value of 2.
Please note that specifying too large of a value could cause Migration Toolkit to terminate, generating a 'Out of heap space' error.
Include the -enableConstBeforeDataLoad option if a non-partitioned source table is mapped to a partitioned table. This option enables all triggers on the target table (including any triggers that redirect data to individual partitions) before the data migration. -enableConstBeforeDataLoad is valid only if the -truncLoad parameter is also specified.
If you are performing a multiple-schema migration, objects that fail to migrate during the first migration attempt due to cross-schema dependencies may successfully migrate during a subsequent migration. Use the -retryCount option to specify the number of attempts that Migration Toolkit will make to migrate an object that has failed during an initial migration attempt. Specify a value that is greater than 0; the default value is 2.
If you include the -safeMode option, 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.
Including the -fastCopy option specifies that Migration Toolkit should bypass WAL logging to perform the COPY operation in an optimized way, default disabled. If you choose to use the -fastCopy option, migrated data may not be recoverable (in the target database) if the migration is interrupted.
However, the Migration Toolkit does not support importation of NULL character values (embedded binary zeros 0x00) with the JDBC connection protocol. If you are importing data that includes the NULL character, use the -replaceNullChar option to replace the NULL character with a single, non-NULL, replacement character. Do not enclose the replacement character in quotes or apostrophes.
Include the -analyze option to invoke the Postgres ANALYZE operation against a target database. The optimizer consults the statistics collected by the ANALYZE operation, utilizing the information to construct efficient query plans.
Include the -vacuumAnalyze option to invoke both the VACUUM and ANALYZE operations against a target database. The optimizer consults the statistics collected by the ANALYZE operation, utilizing the information to construct efficient query plans. The VACUUM operation reclaims any storage space occupied by dead tuples in the target database.
Specify the batch size of bulk inserts. Valid values are 1-1000. The default batch size is 1000; reduce the value of -batchSize if Out of Memory exceptions occur.
Specify the batch Size in MB, to be used in the COPY command. Any value greater than 0 is valid; the default batch size is 8 MB.
Specify the number of rows to be loaded in a batch for LOB data types. The data migration for a table containing a large object type (LOB) column such as BYTEA, BLOB, or CLOB, etc., is performed one row at a time by default. This is to avoid an out of heap space error in case an individual LOB column holds hundreds of megabytes of data. In case the LOB column average data size is at a lower end, you can customize the LOB batch size by specifying the number of rows in each batch with any value greater than 0.
Use the -fetchSize option to specify the number of rows fetched in a result set. If the designated -fetchSize is too large, you may encounter Out of Memory exceptions; include the -fetchSize option to avoid this pitfall when migrating large tables. The default fetch size is specific to the JDBC driver implementation, and varies by database.
-filterProp file_name
file_name specifies the name of a file that contains constraints in key=value pairs. Each record read from the database is evaluated against the constraints; those that satisfy the constraints are migrated. The left side of the pair lists a table name; please note that the table name should not be schema-qualified. The right side specifies a condition that must be true for each row migrated. For example, including the following constraints in the property file:
migrates only those countries with a country_id value that is not equal to AR; this constraint applies to the countries table.
The '\\' characters act as an escape string; since '.' is a reserved character in regular expressions, on Linux use '\\.' to represent the '.' character. For example, to use custom mapping to select rows from the EMP_ID column in the EMP table, specify the following custom mapping entry:
On Windows, use '\.' to represent the '.' character:
You can include multiple custom type mappings in a property_file; specify each entry in the file on a separate line, in a key=value pair. The left side of each pair selects the columns with a regular expression; the right side of each pair names the data type that column should assume.
Import all users and roles from the source database. Please note that the ‑allUsers option is only supported when migrating from an Oracle database to an Advanced Server database.
-users user_list
Import the selected users or roles from the source Oracle database. user_list is a comma-separated list (with no intervening space characters) of user/role names (e.g., -users MTK, SAMPLE, acctg). Please note that the -users option is only supported when migrating from an Oracle database to an Advanced Server database.
All other profile parameters such as the Oracle resource parameters are not imported. The Oracle database user specified by SRC_DB_USER must have SELECT privilege on the Oracle data dictionary view DBA_PROFILES.
Please note that the ‑allProfiles option is only supported when migrating from an Oracle database to an Advanced Server database.
-profiles profile_list
Import the selected, custom (that is, user-created) profiles from the source Oracle database. profile_list is a comma-separated list (with no intervening space characters) of profile names (e.g., -profiles ADMIN_PROFILE,USER_PROFILE). Oracle non-custom profiles such as DEFAULT and MONITORING_PROFILE are not imported.
As with the -allProfiles option, only the password parameters are imported. The Oracle database user specified by SRC_DB_USER must have SELECT privilege on the Oracle data dictionary view DBA_PROFILES.
Please note that the -profiles option is only supported when migrating from an Oracle database to an Advanced Server database.
Include the -importPartitionAsTable parameter to import the contents of a partitioned table that resides on an Oracle host into a single non-partitioned table. table_list is a comma-separated list (with no intervening space characters) of table names (e.g., -importPartitionAsTable emp,dept,acctg).
The dblink_ora module provides Advanced Server-to-Oracle connectivity at the SQL level. dblink_ora is bundled and installed as part of the Advanced Server database installation. dblink_ora utilizes the COPY API method to transfer data between databases. This method is considerably faster than the JDBC COPY method.
The following example uses the dblink_ora COPY API to migrate all tables from the HR schema:
The target Advanced Server database must have dblink_ora installed and configured. For information about dblink_ora, please see Chapter 12 “dblink_ora” in the Database Compatibility for Oracle Developer's Guide, available at:
To migrate all database links using edb as the dummy password for the connected user:
You can alternatively specify the password for each of the database links through a comma-separated list (with no intervening space characters) of name=value pairs. Specify the link name on the left side of the pair and the password value on the right side.
-allSynonyms
Include the -allSynonyms option to migrate all public and private synonyms from an Oracle database to an Advanced Server database. If a synonym with the same name already exists in the target database, the existing synonym will be replaced with the migrated version.
-allPublicSynonyms
Include the -allPublicSynonyms option to migrate all public synonyms from an Oracle database to an Advanced Server database. If a synonym with the same name already exists in the target database, the existing synonym will be replaced with the migrated version.
-allPrivateSynonyms
Include the -allPrivateSynonyms option to migrate all private synonyms from an Oracle database to an Advanced Server database. If a synonym with the same name already exists in the target database, the existing synonym will be replaced with the migrated version.
-useOraCase
Include the -useOraCase option to preserve the Oracle default, uppercase naming convention for all database objects when migrating from an Oracle database to an Advanced Server database.
Note: Within the procedural code body of a procedure, function, trigger or package, identifier references may have to be manually edited in order for the program to execute properly without an error. Such corrections are in regard to the proper case conversion of identifier references that may or may not have occurred.
Note: When the -useOraCase option is specified, the -skipUserSchemaCreation option may need to be specified as well. For information, see the description of the -skipUserSchemaCreation option in this section.
The default behavior of the Migration Toolkit (without using the -useOraCase option) is that database object names are extracted from Oracle without enclosing quotation marks (unless the database object was explicitly created in Oracle with enclosing quotation marks). The following is a sample portion of a table DDL generated by the Migration Toolkit with the -offlineMigration option:
For such desired application usage, perform the migration with the -useOraCase option. The DDL then contains all database object names enclosed in quotes:
-skipUserSchemaCreation
Specification of the -skipUserSchemaCreation option prevents this automatic, schema creation for a migrated Oracle user name. This option is particularly useful when the -useOraCase option is specified in order to prevent creation of two schemas with the same name except for one schema name in lowercase letters and the other in uppercase letters. Specifying the -useOraCase option results in the creation of a schema in the Oracle naming convention of uppercase letters for the source schema specified following the options list when Migration Toolkit is invoked.
Thus, if the -useOraCase option is specified without the -skipUserSchemaCreation option, the target database results in having two identically named schemas with one in lowercase letters and the other in uppercase letters. If the -useOraCase option is specified along with the -skipUserSchemaCreation option, the target database results in having just the schema in uppercase letters.
-logDir log_path
Include this option to specify where the log files will be written; log_path represents the path where application log files are saved. By default, on Linux log files are written to:
-logFileCount file_count
Include this option to specify the number of files used in log file rotation. Specify a value of 0 to disable log file rotation and create a single log file (it will be truncated when it reaches the value specified using the logFileSize option). file_count must be greater than or equal to 0; the default is 20.
-logFileSize file_size
Include this option to have the schema definition (DDL script) of any failed objects saved to a file. The file is saved under the same path that is used for the error logs and is named in the format mtk_bad_sql_schemaname_timestamp.sql where schemaname is the name of the schema and timestamp is the timestamp of the Migration Toolkit run.
7.8 Example
The following is the content of the toolkit.properties file.
You can specify an alternate log file directory with the -logdir log_path option in Migration Toolkit.
Migration Toolkit uses information from the toolkit.properties file to connect to the source and target databases. Most of the connection errors that occur when using Migration Toolkit are related to the information specified in the toolkit.properties file. Use the following section to identify common connection errors, and learn how to resolve them.
For information about editing the toolkit.properties file, see Section 5, Building the toolkit.properties file.
The user name or password specified in the toolkit.properties file is not valid to use to connect to the Oracle source database.
To resolve this error, edit the toolkit.properties file, specifying the name and password of a valid user with sufficient privileges to perform the migration in the SRC_DB_USER and SRC_DB_PASSWORD properties.
The user name or password specified in the toolkit.properties file is not valid to use to connect to the Postgres database.
To resolve this error, edit the toolkit.properties file, specifying the name and password of a valid user with sufficient privileges to perform the migration in the TARGET_DB_USER and TARGET_DB_PASSWORD properties.
To resolve this error, you can either unlock the user account on the Oracle server or edit the toolkit.properties file, specifying the name and password of a valid user with sufficient privileges to perform the migration in the SRC_DB_USER and SRC_DB_PASSWORD parameters.
The JDBC URL for the source database specified in the toolkit.properties file contains invalid connection properties.
To resolve this error, edit the toolkit.properties file, specifying valid connection information for the source database in the SRC_DB_URL property. For information about forming a JDBC URL for your specific database, see Sections 5.1 through 5.6 of this document.
The JDBC URL for the target database (Advanced Server) specified in the toolkit.properties file contains invalid connection properties.
To resolve this error, edit the toolkit.properties file, specifying valid connection information for the target database in the TARGET_DB_URL property. For information about forming a JDBC URL for Advanced Server, see section 5.1 of this document.
Where: COPY table_name, line 5: "50|HR|LOS|ANGELES"
This error occurs when the data in a column in table_name includes the delimiter character. To correct this error, change the delimiter character to a character not found in the table contents.
Note: In this example, the pipe character (|) occurs in the text, LOS|ANGELES, intended for insertion into the last column, and the Migration Toolkit is run using the -copyDelimiter '|' option, which results in the error.
Trying to reload table: TABLE_NAME through bulk inserts with a batch size of 100
You must create a table to receive the data in the target database before you can migrate the data. Verify that a table (with a name of TABLE_NAME ) exists in the target database; create the table if necessary and re-try the data migration.
8.2.3 Error Creating Constraint CONS_NAME_FK
You can avoid generating the error message by including the -skipFKConst option in the Migration Toolkit command.
To correct the problem, specify -fetchSize 1 as a command line argument when you re-try the migration.
•
External tables don't exist in Advanced Server, but you can load flat text files into staging tables in the database. We recommend using the EDB*Loader utility to load the data into an Advanced Server database quickly.
For information about OPERATOR CLASS and OPERATOR FAMILY, see the PostgreSQL core documentation available at:
Migration Toolkit supports the migration of packages from an Oracle database into Advanced Server. See Section 3, Functionality Overview for information about the migration support offered by Advanced Server.
Advanced Server does not currently support the enum data type, but will support them in future releases. Until then, you can use a check constraint to restrict the data added to an Advanced Server database. A check constraint defines a list of valid values that a column may take.
If we test the check constraint by entering a valid dept type, the INSERT statement works without error:
If we try to insert a value not included in the constraint (support), Advanced Server throws an error:
Postgres will have no problem storing TIME data types as long as the value of the hour component is not greater than 24.
Unlike Postgres, the MySQL TIME data type will allow you to store a value that represents either a TIME or an INTERVAL value. A value stored in a MySQL TIME column that represents an INTERVAL value could potentially be out of the accepted range of a valid Postgres TIMESTAMP value. If, during the migration process, Postgres encounters a value stored in a TIME data column that it perceives as out of range, it will return an error.
Each error code begins with the prefix MTK- followed by five digits. The first two digits denote the error class, which is a general classification of the error. The last three digits represent the specific error condition.
If there is an error reported back by a specific database server, this error message is prefixed with DB-. For example, if table creation fails due to an existing table in a Postgres database server, the error code 42P07 is returned by the database server. The specific error in the Migration Toolkit log appears as DB-42P07.
The following sections summarize the Migration Toolkit error codes. In the following tables, column Error Code lists the Migration Toolkit error codes. The Message and Resolution column contains the message displayed with the error code. The message explains the cause of the error and how it is to be resolved.
In the Message and Resolution column, $NAME is a placeholder for information that is substituted at run time with the appropriate value.
Run 'runMTK -help' to see the usage details.
Warning! The offline migration path $OFFLINE_PATH does not exist, the scripts will be created under the user home folder.
You cannot select information_schema, dbo, sys, or pg_catalog as target schemas. These are used to store metadata information in $DATABASE.
The '-schemaOnly' and '-dataOnly' options cannot be specified at the same time.
The ''\\t'' is required as a copyDelimiter, when using escapeTabDelimiter option.
The -truncLoad option can only be given with the -dataOnly option.
The '-dataOnly' option is applicable only for -allTables/-tables option. Schema DDL cannot be copied when this option is in place.
The -constraints, -indexes and -triggers options are applicable only in the context of -allTables/-tables option.
The '-vacuumAnalyze' and '-analyze' options cannot be specified at the same time.
The -skipFKConst option can only be given with -constraints option.
The -skipCKConst option can only be given with -constraints option.
The -fastCopy option cannot be specified with -schemaOnly option.
The -skipColDefaultClause cannot be specified with -dataOnly option.
The '-customColTypeMapping' and '-customColTypeMappingFile' options cannot be specified at the same time.
Provided default date time must be in following format 'yyyy-MM-dd_HH:mm:ss'. Time portion is optional, to specify time, the underscore symbol '_' is necessary.
The -targetDBVersion value should be specified using major.minor pattern.
The -targetDBVersion can only be used with -offlineMigration mode.
Options (-constraints | -indexes | -triggers | -tables | -views | -sequences | -procs | -funcs | -packages | -synonyms) cannot be used with multiple schemas option.
The -allSchemas option should be specified as the last option in the command-line options list.
You have specified invalid command-line arguments. Run 'runMTK -help' to see the usage details.
The -replaceNullChar cannot be specified with -schemaOnly option.
The -nullReplacementChar can only be specified with -replaceNullChar option.
The -ignoreCheckConstFilter can only be given with -constraints option.
The -enableConstBeforeDataLoad can only be given with -truncLoad option.
The retryCount value should be greater than 0.
Invalid number for retryCount, use a number > 0.
The loaderCount value should be greater than 0.
Invalid number for loaderCount, use a number > 0.
Cannot use singleDataFile option for offline data migration in COPY format.
The $SCHEMA cannot be used as schema name in $DATABASE. Choose a different schema name via -targetSchema option.
The copyViaDBLinkOra option can only be used for copying data from Oracle to EnterpriseDB.
The -recreateConst option can only be given with the -dataOnly option.
The $DATABASE database type is not supported by Migration Toolkit. Specify a valid database type string (i.e., EnterpriseDB, Postgres, Oracle, SQLServer, Sybase, or MySQL).
The URL specified for the $DATABASE database is invalid. Check the connectivity credentials.
The -escapeKeywords value may be true or false.
The -useOraCase option can only be used for migration from Oracle.
The URL specified for the Oracle database is not supported by dblink_ora. Check the connectivity credentials and provide a valid URL.
The schema $SCHEMA not found on source database.
This class represents invalid configuration settings provided in the toolkit.properties file or in any other configuration file used by the Migration Toolkit.
Error loading $DBLINKORA_FILE file.
Error while loading DBLink Ora module. $DBLINKORA_MODULE. Verify that dblink_ora is installed/configured on target EnterpriseDB server. Please see the Database Compatibility for Oracle Developer's Guide for more information about installing and configuring the dblink_ora module.
Error while loading given DBLink_Ora module. $DBLINKORA_MODULE. Verify that dblink_ora is installed/configured on target EnterpriseDB server. Please see the Database Compatibility for Oracle Developer's Guide for more information about installing and configuring the dblink_ora module.
The connection credentials file $TOOLKIT_PROP_FILE is not secure and accessible to group/others users. This file contains plain passwords and should be restricted to Migration Toolkit owner user only.
The user/role migration failed due to insufficient privileges. Grant the user SELECT privilege on the following Oracle catalogs: DBA_ROLES, DBA_USERS, DBA_TAB_PRIVS, DBA_PROFILES, DBA_ROLE_PRIVS, ROLE_ROLE_PRIVS, DBA_SYS_PRIVS.
The migration of privileges failed due to insufficient privileges. Grant the user SELECT privilege on the following Oracle catalog: dba_tab_privs.
For $DATABASE views migration is not supported.
For $DATABASE roles migration is not supported.
The given trigger is not migrated, the trigger has WHEN clause which is not supported by EnterpriseDB.
Skipping Database Link $DATABASE_LINK. EnterpriseDB currently does not support this type of Database Link.
Warning! Skipping migration of trigger $TRIGGER, currently non-table triggers are not supported in target database.
Rules are not supported in $DATABASE database.
$TYPE is Not Supported by COPY.
Groups are not supported in $DATABASE database.
Profile migration is not supported in $SRC_DB to $TARGET_DB permutation.
Password Profile verify function $MY_VERIFICATION_FUNCTION must be explicitly migrated.
Advanced Queues migration is not supported from $SRC_DB database to $TARGET_DB database.
The INTERVAL partition is not supported in $DATABASE, the table will be migrated without INTERVAL definition.
Warning! User profile migration is not supported in target database version $VERSION. The profile "$PROFILE" for user "$USER" will be skipped.
One or more tables couldn't be found in the source $DATABASE database. With -tables mode, the table name should be in uppercase unless it is case-sensitive.
One or more users couldn't be found in the source $DATABASE database. With -users mode, the user name should be in uppercase unless it is case-sensitive.
Error granting given privilege $PRIVILEGE on $OBJECT to $USER.
Error granting $ROLE to $USER.
The table $TABLE could not be created in $DATABASE database.
The linked schema $LINKED_SCHEMA doesn't exist in the target database. Create the schema and then retry.
Table name $TABLE does not have a schema qualifier. With multiple schema migration context, each table should be schema qualified.
Schema qualifier $SCHEMA does not match the schema list.
Package Body is invalid, skipping... Note: This error message also appears when a package specification is successfully migrated, but there is no corresponding package body in the source database. In this case, the package specification should function properly in the target database despite the appearance of the error message.