Extraction utility (dbxtract)

To extract a remote database from a consolidated SQL Anywhere database.

Syntax
dbxtract [ options ] [ directory ] subscriber
Option Description
@data

Read in options from a configuration file. See @data server option.

Use this option to read in options from the specified environment variable or configuration file. If both exist with the same name, the environment variable is used. See Using configuration files.

If you want to protect passwords or other information in the configuration file, you can use the File Hiding utility to obfuscate the contents of the configuration file. See File Hiding utility (dbfhide).

-ac "keyword=value; ..."

Connect to the database specified in the connection string to do the reload.

You can combine the operation of unloading a database and reloading the results into an existing database using this option.

For example, the following command (entered all on one line) loads a copy of the data for the field_user subscriber into an existing database file named c:\field.db:

dbxtract -c "UID=DBA;PWD=sql;DBF=c:\cons.db" 
-ac "UID=DBA;PWD=sql;DBF=c:\field.db" field_user

If you use this option, no copy of the data is created on disk, so you do not specify an unload directory in the command. This provides greater security for your data, but at some cost for performance.

-al filename Specify the transaction log file name for the new database if using the -an option.
-an database

Create a database file with the same settings as the database being extracted and automatically reload it.

You can combine the operations of unloading a database, creating a new database, and loading the data using this option.

For example, the following command (entered all on one line) creates a new database file named c:\field.db and copies the schema and data for the field_user subscriber of c:\cons.db into it:

dbxtract -c "UID=DBA;PWD=sql;DBF=c:\cons.db" 
-an c:\field.db field_user

If you use this option, no copy of the data is created on disk, so you do not specify an unload directory in the command. This provides greater security for your data, but at some cost for performance.

-ap size

Set the page size of the new database. This option is ignored unless -an is used. The page size for a database can be (in bytes) 2048, 4096, 8192, 16384, or 32768, with the default being the page size of the original database. If there are already databases running on the database server, the server's page size (set with the -gp option) must be large enough to handle the new page size. See -gp server option.

-b

Do not start subscriptions. If this option is specified, subscriptions at the consolidated database (for the remote database) and at the remote database (for the consolidated database) must be started explicitly using the START SUBSCRIPTION statement for replication to begin. See START SUBSCRIPTION statement [SQL Remote].

-c "keyword=value; ..."

Supply database connection parameters, in a string:

The user ID should have DBA authority to ensure that the user has permissions on all the tables in the database.

For example, the following statement (entered all on one line) extracts a database for remote user ID joe_remote from the sample database running on the sample_server database server, connecting as user ID DBA with password sql. The data is unloaded into the c:\extract directory.

dbxtract -c "ENG=sample_server;DBN=demo;
UID=DBA;PWD=sql" c:\extract joe_remote

If connection parameters are not specified, connection parameters from the SQLCONNECT environment variable are used, if set.

-d

Extract data only. If this option is specified, the schema definition is not unloaded and publications and subscriptions are not created at the remote database. This option is used when a remote database already exists with the proper schema, and only needs to be filled with data.

-ea alg

Specify the encryption algorithm for the new database. This option allows you to choose a strong encryption algorithm to encrypt your new database. You can choose either AES (the default) or AES_FIPS for the FIPS-approved algorithm. AES_FIPS uses a separate library and is not compatible with AES.

For greater security, specify AES or AES256 for 128-bit or 256-bit strong encryption, respectively. Specify AES_FIPS or AES256_FIPS for 128-bit or 256-bit FIPS-approved encryption, respectively. For strong encryption, you must also specify the -ek or -ep option. For more information about strong encryption, see Strong encryption.

To create a database that is not encrypted, specify -ea none, or do not include the -ea option (and do not specify -e, -et, -ep, or -et).

If you do not specify the -ea option, the default behavior is as follows:

  • -ea none, if -ek, -ep, or -et is not specified
  • -ea AES, if -ek or -ep is specified (with or without -et)
  • -ea simple, if -et is used without -ek or -ep

Algorithm names are case insensitive.

Separately licensed component required

ECC encryption and FIPS-certified encryption require a separate license. All strong encryption technologies are subject to export regulations.

See Separately licensed components.

-ek key

Specify the encryption key for the new database. This option allows you to create a strongly encrypted database by specifying an encryption key directly in the command. The algorithm used to encrypt the database is AES or AES_FIPS as specified by the -ea option. If you specify the -ek option without specifying -ea, the AES algorithm is used.

Caution

For strongly encrypted databases, be sure to store a copy of the key in a safe location. If you lose the encryption key, there is no way to access the data, even with the assistance of technical support. The database must be discarded and you must create a new database.

-ep

Prompt for the encryption key for the new database. This option specifies that you want to create a strongly encrypted database by typing the encryption key in a window. This provides an extra measure of security by never allowing the encryption key to be seen in clear text.

You must input the encryption key twice to confirm that it was entered correctly. If the keys don't match, the initialization fails. See Strong encryption.

-er

Remove encryption from encrypted tables during an unload procedure.

When extracting from a database that has table encryption enabled, you must specify either -er or -et to indicate whether the new database has table encryption enabled, otherwise you get an error when attempting to load the data into the new database.

The following command extracts a database (cons.db) that has encrypted tables, into a new database (field.db) that does not have table encryption enabled, removing encryption from any encrypted tables:

dbxtract -an c:\field.db -er -c "UID=DBA;PWD=sql;DBF=c:\cons.db;DBKEY=29bN8cj1z field_user"
-et

Enable database table encryption in the new database (-an or -ar must also be specified). If you specify the -et option without the -ea option, the AES algorithm is used. If you specify the -et option, you must also specify -ep or -ek. You can change the table encryption settings for the new database to be different from those of the database you are unloading.

When rebuilding a database that has table encryption enabled, you must specify either -er or -et to indicate whether the new database has table encryption enabled, otherwise you get an error when attempting to load the data into the new database.

The following example unloads a database (cons.db) that has tables encrypted with the simple encryption algorithm, into a new database (field.db) that has table encryption enabled, and uses AES_FIPS encryption with the key 34jh:

dbxtract -an c:\field.db -et -ea AES_FIPS -ek 34jh -c "UID=DBA;PWD=sql;DBF=c:\cons.db field_user"
-f

Extract fully qualified publications. In most cases, you do not need to extract fully qualified publication definitions for the remote database, since it typically replicates all rows back to the consolidated database.

However, you may want fully qualified publications for multi-tier setups or for setups where the remote database has rows that are not in the consolidated database.

-ii

Perform an internal unload and internal reload. Using this option forces the reload script to use the internal UNLOAD and LOAD TABLE statements rather than the Interactive SQL OUTPUT and INPUT statements to unload and load data, respectively. This combination of operations is the default behavior.

External operations take the path of the data files relative to the current working directory of dbxtract, while internal statements take the path relative to the database server.

-ix

Perform an internal unload and external reload. Using this option forces the reload script to use the internal UNLOAD statement to unload data, and the Interactive SQL INPUT statement to load the data into the new database.

External operations take the path of the data files relative to the current working directory of dbxtract, while internal statements take the path relative to the database server.

-l level

Perform all extraction operations at specified isolation level. The default setting is an isolation level of 0. If you are extracting a database from an active database server, you should run it at isolation level 3 to ensure that data in the extracted database is consistent with data on the database server. Increasing the isolation level may result in large numbers of locks being used by the Extraction utility (dbxtract), and may restrict database use by other users. See Extraction utility (dbxtract).

-n

Extract the schema definition only. With this definition, none of the data is unloaded. The reload file contains SQL statements to build the database schema only. You can use the SYNCHRONIZE SUBSCRIPTION statement to load the data over the messaging system. Publications, subscriptions, PUBLISH, and SUBSCRIBE permissions are part of the schema.

dbxtract -c "UID=DBA;PWD=sql;DBF=c:\remote\cons\cons.db" -n "c:\remote\reload.sql" UserName
-nl

Extract the structure (the same behavior as the -n option), but the resulting reload.sql file also includes LOAD TABLE or INPUT statements for each table. No user data is extracted when this option is used. When you specify -nl, you must also include a data directory so that the LOAD/INPUT statements can be generated, even though no files are written to the directory. This option allows you to generate a reload script without unloading data. You can extract the data by specifying -d. If a database contains a table whose data should not be unloaded, you can avoid unloading the data for that table by using dbxtract -d -e table-name.

-o file

Output messages to an output log file.

-p character

Specify an escape character. The default escape character (\) can be replaced by another character using this option.

-q

Operate quietly: do not display messages or show windows. When this option is specified, -y must also be specified or the operation fails.

This option is available only for the command line utility.

-r file

Specify the name of the generated reload Interactive SQL command file.

The default name for the reload command file is reload.sql in the current directory. You can specify a different file name with this option.

-u

Do not order data during the unload. By default, the data in each table is ordered by primary key. Unloads are faster with the -u option, but loading the data into the remote database is slower.

-v

Display verbose messages. The name of the table being unloaded, the number of rows unloaded, and the SELECT statement used.

-xf

Exclude foreign keys. You can use this option if the remote database contains a subset of the consolidated database schema, and some foreign key references are not present in the remote database.

-xh Exclude procedure hooks.
-xi

Perform an external unload and internal reload. The default behavior for unloading the database is to use the UNLOAD statement, which is executed by the database server. If you choose an external unload, dbxtract uses the OUTPUT statement instead. The OUTPUT statement is executed on the client.

External operations take the path of the data files relative to the current working directory of dbxtract, while internal statements take the path relative to the database server.

-xp

Do not extract stored procedures from the database.

-xt

Do not extract triggers from the database.

-xv

Do not extract views from the database.

-xx

Perform an external unload and an external load. Use the OUTPUT statement to unload the data, and the INPUT statement to load the data into the new database.

The default unload behavior is to use the UNLOAD statement, and the default loading behavior is to use the LOAD TABLE statement. The internal UNLOAD and LOAD TABLE statements are faster than OUTPUT and INPUT.

External operations take the path of the data files relative to the current working directory of dbxtract, while internal statements take the path relative to the database server.

-y

Overwrite the command file without confirmation. Without specifying this option, you are prompted to confirm the replacement of an existing command file.

directory Specify the directory the files are written to. This is not needed if you specify -an or -ac .
subscriber Specify the subscriber for whom the database is being extracted.
Remarks

By default, the Extraction utility (dbxtract) runs at isolation level zero. If you are extracting a database from an active database server, you should run it at isolation level 3 to ensure that data in the extracted database is consistent with data on the database server. Running at isolation level 3 may hamper others' turnaround time on the database server because of the large number of locks required. It is recommended that you run the Extraction utility (dbxtract) when the database server is not busy, or run it against a copy of the database.

The Extraction utility (dbxtract) creates a command file and a set of associated data files. The command file can be run against a newly-initialized database to create the database objects and load the data for the remote database.

By default, the command file is named reload.sql.

If the remote user is a group, then all the user IDs that are members of that group are extracted. This allows multiple users on a remote database with different user IDs, without requiring a custom extraction process.

When using the Extraction utility (dbxtract) or the Extract Database Wizard with a version 10.0.0 or later database, the version of dbxtract used must match the version of the database server used to access the database. If an older version of dbxtract is used with a newer database server, or vice versa, an error is reported.

The Extraction utility (dbxtract) and Extract Database Wizard do not unload the objects created for the dbo user ID during database creation. Changes made to these objects, such as redefining a system procedure, are lost when the data is unloaded. Any objects created by the dbo user ID since the initialization of the database are unloaded by the Extraction utility (dbxtract), and so these objects are preserved.

See also