DB2 Version 9.7 for Linux, UNIX, and Windows

db2move - Database movement tool command

This tool, when used in the EXPORT/IMPORT/LOAD mode, facilitates the movement of large numbers of tables between DB2® databases located on workstations. The tool queries the system catalog tables for a particular database and compiles a list of all user tables. It then exports these tables in PC/IXF format. The PC/IXF files can be imported or loaded to another local DB2 database on the same system, or can be transferred to another workstation platform and imported or loaded to a DB2 database on that platform. Tables with structured type columns are not moved when this tool is used. When used in the COPY mode, this tool facilitates the duplication of a schema.

Authorization

This tool calls the DB2 export, import, and load APIs, depending on the action requested by the user. Therefore, the requesting user ID must have the correct authorization required by those APIs, or the request will fail.

Command syntax

Read syntax diagramSkip visual syntax diagram
                            .----------------------------.   
                            V                            |   
>>-db2move--dbname--action----+------------------------+-+-----><
                              +- -tc--table-definers---+     
                              +- -tn--table-names------+     
                              +- -sn--schema-names-----+     
                              +- -ts--tablespace-names-+     
                              +- -tf--filename---------+     
                              +- -io--import-option----+     
                              +- -lo--load-option------+     
                              +- -co--copy-option------+     
                              +- -l--lobpaths----------+     
                              +- -u--userid------------+     
                              +- -p--password----------+     
                              '- -aw-------------------'     

Command parameters

dbname
Name of the database.
action
Must be one of:
EXPORT
Exports all tables that meet the filtering criteria in options. If no options are specified, exports all the tables. Internal staging information is stored in the db2move.lst file.
IMPORT
Imports all tables listed in the internal staging file db2move.lst. Use the -io option for IMPORT specific actions.
LOAD
Loads all tables listed in the internal staging file db2move.lst. Use the -lo option for LOAD specific actions.
COPY
Duplicates schemas into a target database. The target database must be a local database. Use the -sn option to specify one or more schemas. See the -co option for COPY specific options. Use the -tn or -tf option to filter tables in LOAD_ONLY mode. You must use a table space named SYSTOOLSPACE when either the ADMIN_COPY_SCHEMA() stored procedure is used, or when the db2move utility is used with the -COPY option.
See below for a list of files that are generated during each action.
-tc table-definers
The default is all definers.

This is an EXPORT action only. If specified, only those tables created by the definers listed with this option are exported. If not specified, the default is to use all definers. When specifying multiple definers, they must be separated by commas; no blanks are allowed between definer IDs. This option can be used with the -tn table-names option to select the tables for export.

An asterisk (*) can be used as a wildcard character that can be placed anywhere in the string.

-tn table-names
The default is all user tables.

This is an EXPORT or COPY action only.

If specified with the EXPORT action, only those tables whose names match those in the specified string are exported. If not specified, the default is to use all user tables. When specifying multiple table names, they must be separated by commas; no blanks are allowed between table names. Table names should be listed unqualified and the -sn option should be used to filter schemas.

For export, an asterisk (*) can be used as a wildcard character that can be placed anywhere in the string.

If specified with the COPY action, the -co "MODE" LOAD_ONLY copy-option must also be specified, and only those tables specified will be repopulated on the target database. The table names should be listed with their schema qualifier in the format "schema"."table".

-sn schema-names
The default for EXPORT is all schemas (not for COPY).

If specified, only those tables whose schema names match will be exported or copied. If multiple schema names are specified, they must be separated by commas; no blanks are allowed between schema names. Schema names of less than 8 characters are padded to 8 characters in length.

In the case of export: If the asterisk wildcard character (*) is used in the schema names, it will be changed to a percent sign (%) and the table name (with percent sign) will be used in the LIKE predicate of the WHERE clause. If not specified, the default is to use all schemas. If used with the -tn or -tc option, db2move will only act on those tables whose schemas match the specified schema names and whose definers match the specified definers. A schema name fred has to be specified -sn fr*d* instead of -sn fr*d when using an asterisk.

Note: The -sn option is not supported on DB2 for z/OS.
-ts tablespace-names
The default is all table spaces.

This is an EXPORT action only. If this option is specified, only those tables that reside in the specified table space will be exported. If the asterisk wildcard character (*) is used in the table space name, it will be changed to a percent sign (%) and the table name (with percent sign) will be used in the LIKE predicate in the WHERE clause. If the -ts option is not specified, the default is to use all table spaces. If multiple table space names are specified, they must be separated by commas; no blanks are allowed between table space names. Table space names less than 8 characters are padded to 8 characters in length. For example, a table space name mytb has to be specified -ts my*b* instead of -sn my*b when using the asterisk.

-tf filename
If specified with EXPORT action, only those tables whose names match exactly those in the specified file are exported. If not specified, the default is to use all user tables. The tables should be listed one per line, and each table should be fully qualified. Wildcard characters are not allowed in the strings. Here is an example of the contents of a file:
   "SCHEMA1"."TABLE NAME1"
   "SCHEMA NAME77"."TABLE155"

If specified with the COPY action, the -co "MODE" LOAD_ONLY copy-option must also be specified, and only those tables specified in the file will be repopulated on the target database. The table names should be listed with their schema qualifier in the format "schema"."table".

-io import-option
The default is REPLACE_CREATE. See "IMPORT command options CREATE and REPLACE_CREATE are deprecated" for limitations of import create function.

Valid options are: INSERT, INSERT_UPDATE, REPLACE, CREATE, and REPLACE_CREATE.

-lo load-option
The default is INSERT.

Valid options are: INSERT and REPLACE.

-co
When the db2move action is COPY, the following -co follow-on options will be available:
"TARGET_DB db name [USER userid USING password]"
Allows the user to specify the name of the target database and the user/password. (The source database user/password can be specified using the existing -p and -u options). The USER/USING clause is optional. If USER specifies a userid, then the password must either be supplied following the USING clause, or if it's not specified, then db2move will prompt for the password information. The reason for prompting is for security reasons discussed below. TARGET_DB is a mandatory option for the COPY action. The TARGET_DB cannot be the same as the source database and must be a local database. The ADMIN_COPY_SCHEMA procedure can be used for copying schemas within the same database. The COPY action requires inputting at least one schema (-sn) or one table (-tn or -tf).

Running multiple db2move commands to copy schemas from one database to another will result in deadlocks. Only one db2move command should be issued at a time. Changes to tables in the source schema during copy processing may mean that the data in the target schema is not identical following a copy.

"MODE"
DDL_AND_LOAD
Creates all supported objects from the source schema, and populates the tables with the source table data. This is the default option.
DDL_ONLY
Creates all supported objects from the source schema, but does not repopulate the tables.
LOAD_ONLY
Loads all specified tables from the source database to the target database. The tables must already exist on the target. The LOAD_ONLY mode requires inputting at least one table using the -tn or -tf option.

This is an optional option that is only used with the COPY action.

"SCHEMA_MAP"
Allows user to rename schema when copying to target. Provides a list of the source-target schema mapping, separated by commas, surrounded by brackets. e.g schema_map ((s1, t1), (s2, t2)). This would mean objects from schema s1 will be copied to schema t1 on the target; objects from schema s2 will be copied to schema t2 on the target. The default, and recommended, target schema name is the source schema name. The reason for this is db2move will not attempt to modify the schema for any qualified objects within object bodies. Therefore, using a different target schema name may lead to problems if there are qualified objects within the object body.

For example:

create view FOO.v1 as 'select c1 from FOO.t1'

In this case, copy of schema FOO to BAR, v1 will be regenerated as:

create view BAR.v1 as 'select c1 from FOO.t1'

This will either fail since schema FOO does not exist on the target database, or have an unexpected result due to FOO being different than BAR. Maintaining the same schema name as the source will avoid these issues. If there are cross dependencies between schemas, all inter-dependant schemas must be copied or there may be errors copying the objects with the cross dependencies.

For example:

create view FOO.v1 as 'select c1 from BAR.t1'

In this case, the copy of v1 will either fail if BAR is not copied as well, or have an unexpected result if BAR on the target is different than BAR from the source. db2move will not attempt to detect cross schema dependencies.

This is an optional option that is only used with the COPY action.

If a target schema already exists, the utility will fail. Use the ADMIN_DROP_SCHEMA procedure to drop the schema and all objects associated with that schema.

"NONRECOVERABLE"
This option allows the user to override the default behavior of the load to be done with COPY-NO. With the default behavior, the user will be forced to take backups of each table space that was loaded into. When specifying this NONRECOVERABLE keyword, the user will not be forced to take backups of the table spaces immediately. It is, however, highly recommended that the backups be taken as soon as possible to ensure the newly created tables will be properly recoverable. This is an optional option available to the COPY action.
"OWNER"
Allows the user to change the owner of each new object created in the target schema after a successful COPY. The default owner of the target objects will be the connect user; if this option is specified, ownership will be transferred to the new owner. This is an optional option available to the COPY action.
"TABLESPACE_MAP"
The user may specify table space name mappings to be used instead of the table spaces from the source system during a copy. This will be an array of table space mappings surrounded by brackets. For example, tablespace_map ((TS1, TS2),(TS3, TS4)). This would mean that all objects from table space TS1 will be copied into table space TS2 on the target database and objects from table space TS3 will be copied into table space TS4 on the target. In the case of ((T1, T2),(T2, T3)), all objects found in T1 on the source database will be recreated in T2 on the target database and any objects found in T2 on the source database will be recreated in T3 on the target database. The default is to use the same table space name as from the source, in which case, the input mapping for this table space is not necessary. If the specified table space does not exist, the copy of the objects using that table space will fail and be logged in the error file.

The user also has the option of using the SYS_ANY keyword to indicate that the target table space should be chosen using the default table space selection algorithm. In this case, db2move will be able to choose any available table space to be used as the target. The SYS_ANY keyword can be used for all table spaces, example: tablespace_map SYS_ANY. In addition, the user can specify specific mappings for some table spaces, and the default table space selection algorithm for the remaining. For example, tablespace_map ((TS1, TS2),(TS3, TS4), SYS_ANY). This indicates that table space TS1 is mapped to TS2, TS3 is mapped to TS4, but the remaining table spaces will be using a default table space target. The SYS_ANY keyword is being used since it's not possible to have a table space starting with "SYS".

This is an optional option available to the COPY action.

-l lobpaths
For IMPORT and EXPORT, if this option is specified, it will be also used for XML paths. The default is the current directory.

This option specifies the absolute path names where LOB or XML files are created (as part of EXPORT) or searched for (as part of IMPORT or LOAD). When specifying multiple paths, each must be separated by commas; no blanks are allowed between paths. If multiple paths are specified, EXPORT will use them in round-robin fashion. It will write one LOB document to the first path, one to the second path, and so on up to the last, then back to the first path. The same is true for XML documents. If files are not found in the first path (during IMPORT or LOAD), the second path will be used, and so on.

-u userid
The default is the logged on user ID.

Both user ID and password are optional. However, if one is specified, the other must be specified. If the command is run on a client connecting to a remote server, user ID and password should be specified.

-p password
The default is the logged on password. Both user ID and password are optional. However, if one is specified, the other must be specified. When the -p option is specified, but the password not supplied, db2move will prompt for the password. This is done for security reasons. Inputting the password through command line creates security issues. For example, a ps -ef command would display the password. If, however, db2move is invoked through a script, then the passwords will have to be supplied. If the command is issued on a client connecting to a remote server, user ID and password should be specified.
-aw
Allow Warnings. When -aw is not specified, tables that experience warnings during export are not included in the db2move.lst file (although that table's .ixf file and .msg file are still generated). In some scenarios (such as data truncation) the user might want to allow such tables to be included in the db2move.lst file. Specifying this option allows tables which receive warnings during export to be included in the .lst file.

Examples

Usage notes

Files Required/Generated When Using EXPORT:

Files Required/Generated When Using IMPORT:

Files Required/Generated When Using LOAD:

Files Required/Generated When Using COPY: