Translates a transaction log into a SQL command file.
Running against a database server:
dbtran [ options ] -c { connection-string } -n SQL-file
Running against a transaction log:
dbtran [ options ] [ transaction-log ] [ SQL-file ]
Option | Description | ||
---|---|---|---|
@data |
Reads in options from the specified environment variable or configuration file. 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). |
||
-a |
Controls whether uncommitted transactions appear in the transaction log. The transaction log contains changes made before the most recent COMMIT by any transaction. Changes made after the most recent commit are not present in the transaction log. If -a is not specified, only committed transactions appear in the output file. If -a is specified, any uncommitted transactions found in the transaction log are output followed by a ROLLBACK statement. |
||
-c "keyword=value; ..." | Specifies the connection string when running the utility against a database server. See Connection parameters. | ||
-d | Specifies that transactions are written in order from earliest to latest. This feature is provided primarily for use when auditing database activity: the output of dbtran should not be applied against a database. | ||
-ek key |
Specifies the encryption key for strongly encrypted databases. If you have a strongly encrypted database, you must provide the encryption key to use the database or transaction log. For strongly encrypted databases, you must specify either -ek or -ep, but not both. The command fails if you do not specify the correct encryption key. If you are running dbtran against a database server using the -c option, specify the key using a connection parameter instead of using the -ek option. For example, the following command gets the transaction log information about database myenc.db from the database server sample, and saves its output in log.sql.
|
||
-ep |
Prompts for the encryption key. This option causes a window to appear, in which you enter the encryption key. It provides an extra measure of security by never allowing the encryption key to be seen in clear text. For strongly encrypted databases, you must specify either -ek or -ep, but not both. The command fails if you do not specify the correct encryption key. If you are running dbtran against a database server using the -c option, specify the key using a connection parameter, instead of using the -ep option. For example, the following command gets the transaction log information about database myenc.db from the database server sample, and saves its output in log.sql.
|
||
-f | Outputs only transactions that were completed since the last checkpoint. | ||
-g |
Adds auditing information to the transaction log if the auditing database option is turned on. You can include this information as comments in the output file using this option. See auditing option. The -g option implies the -a, -d, and -t options. |
||
-ir offset1,offset2 | Outputs a portion of the transaction log between two specified offsets. | ||
-is source,... |
Outputs operations on rows that have been modified by operations from one or more of the following sources, specified as a comma-separated list:
|
||
-it owner.table,... | Outputs those operations on the specified, comma-separated list of tables. Each table should be specified as owner.table. | ||
-j date/time | Translates only transactions from the most recent checkpoint before the given date and/or time. The user-provided argument can be a date, time, or date and time, enclosed in quotes. If the time is omitted, the time is assumed to be the beginning of the day. If the date is omitted, the current day is assumed. The following is an acceptable format for the date and time: "YYYY/MMM/DD HH:NN". | ||
-k | Prevents partial .sql files from being erased if an error is detected. If an error is detected while dbtran is running, the .sql file generated until that point is normally erased to ensure that a partial file is not used by accident. Specifying this option may be useful if you are attempting to salvage transactions from a damaged transaction log. | ||
-m | Specifies a directory that contains transaction logs. This option must be used in conjunction with the -n option. | ||
-n filename | Specifies the output file that holds the SQL statements when you run the dbtran utility against a database server. | ||
-o filename | Writes output messages to the named file. | ||
-q | Runs in quiet mode—messages are not displayed. | ||
-r | Removes any transactions that were not committed. This is the default behavior. | ||
-s | Controls how UPDATE statements are generated. If the option is not used, and there is no primary key or unique index on a table, the Log Translation utility generates UPDATE statements with a non-standard FIRST keyword if there are duplicate rows. If the option is used, the FIRST keyword is omitted for compatibility with the SQL standard. | ||
-sr | Places generated comments in the output file describing how SQL Remote distributes operations to remote sites. | ||
-t | Controls whether triggers are included in the command file. By default, actions performed by triggers are not included in the command file. If the matching trigger is in the database, when the command file is run against the database the trigger performs the actions automatically. Trigger actions should be included if the matching trigger does not exist in the database against which the command file is to run. | ||
-u userid,... | Limits the output from the transaction log to include only specified users. | ||
-x userid,... | Limits the output from the transaction log to exclude specified users. | ||
-y | Replaces existing command files without prompting you for confirmation. If you specify -q, you must also specify -y or the operation fails. | ||
-z | Includes transactions that were generated by triggers only as comments in the output file. | ||
transaction-log | Specifies the log file to be translated. Cannot be used together with -c or -m options. | ||
SQL-file | Names the output file containing the translated information. For use with transaction-log only. |
The dbtran utility takes the information in a transaction log and places it as a set of SQL statements and comments into an output file. The utility can be run in the following ways:
Against a database server When dbtran is run against a database server, the utility is a standard client application. It connects to the database server using the connection string specified following the -c option, and places output in a file specified with the -n option. DBA authority is required to run in this way.
The following command translates log information from the server demo12 and places the output in a file named demo.sql.
dbtran -c "Server=demo12;DBN=demo;UID=DBA;PWD=sql" -n demo.sql |
Against a transaction log file When dbtran is run against a transaction log, the utility acts directly against a transaction log file. You should protect your transaction log file from general access if you want to prevent users from having the capability of running this statement.
dbtran demo.log demo.sql |
When the dbtran utility runs, it displays the earliest log offset in the transaction log. This can be an effective method for determining the order in which multiple log files were generated.
If -c is used, dbtran attempts to translate the online transaction log file, and all the offline transaction log files in the same directory as the online transaction log file. If the directory contains transaction log files for more than one database, dbtran may give an error. To avoid this problem, ensure that each directory contains transaction log files for only one database.
A transaction can span multiple transaction logs. If transaction log files contain transactions that span logs, translating
a single transaction log file (for example dbtran demo.log
) can cause the spanning transactions to be lost. In order for dbtran to generate complete transactions, use the -c or -m
options with the transaction log files in the directory. See Recovering a database with multiple transaction logs.
You can access the Log Translation utility in the following ways:
From Sybase Central, using the Translate Log File Wizard.
At a command prompt, using the dbtran command. This is useful for incorporation into batch or command files.
Exit codes are 0 (success) or non-zero (failure). See Software component exit codes.
Discuss this page in DocCommentXchange.
|
Copyright © 2010, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.0 |