Product Documentation

Database Integrity Utilities

Previous Topic

Next Topic

dbdump - Data Unload Utility

The dbdump utility writes the data in a database to a file. The format of the exported data is specified by the record description given in an input command file.

Operational Model:

  • Client

The dbdump command accepts the commands file name, the database name and a command option.

Syntax

dbdump -f commands_file [-u user_name] [-a password] [-n] [‑z] [-p] [‑l] database_name

Options

  • -f commands_file - Specifies the file containing dbdump commands.
  • -u user_name - The user name c-treeSQL uses to connect to the database. If omitted, the default value depends on the environment. (On UNIX, the value of the DH_USER environment variable specifies the default user name. If DH_USER is not set, the value of the USER environment variable specifies the default user name.)
  • -a password - The password c-treeSQL uses to connect to the database. If omitted, the default value depends on the environment. (On UNIX, the value of the DH_PASSWD environment variable specifies the default password.)
  • -n - Parse the commands file and display errors, if any, without exporting data. If the parsing is successful, the following message displays on stdout:

No errors in the commands file.

  • ‑z (V10.3 and later) - The number of records to fetch per call is controlled by the ‑z switch. To be consistent with the switch of dbload, it defaults to 1.
  • ‑l (V10.3 and later) - The ‑l switch controls the progress output frequency in terms of record reads (the output is generated whenever the number of record reads since the last output becomes greater than or equal to the specified value).
  • -p (V10.3 and later) - The dbdump -p command-line switch activates the new query passthru mechanism, which does not perform any major change in the query. When this switch is in use, dbdump interprets the query in the command file, converts it to lowercase, and wraps everything that is considered an identifier with double-quotes. This can cause a syntax error if the command file contains functions. For example, consider the following statement:

SELECT RTRIM(cm_custnumb),...

The default behavior of dbdump results in the following statement, which would cause a syntax error:

select "rtrim" ( "cm_custnumb" ) ,...

Using the dbdump -p switch results in this statement, which does not cause an error:

select rtrim ( cm_custnumb ) ,...

  • database_name - Name of the database.
  • -B - Use BOM (Unicode Byte Order Mark) in output file.
  • -S BASIC | <cert_filename> - Basic TLS encryption or cross checked authentication using <cert_filename>

Automatic Record Definition

Customers have a need to export all data in a CSV format. dbdump is great for this purpose. (In general, dbdump primary usage is with SELECT * FROM ...) However, with large tables, there is a lot of setup work to create the DEFINE RECORD information. For example, for a table with more than 100 columns, they have to manually describe the complete output structure for all fields.

In V11.5 and later we have introduced a new syntax in the DBDUMP script to automatically generate the record definition. The syntax definition for the commands file is as shown:

dbdump_commands:

define_record_statement

for_record_statement

where define_record_statement is either the following (existing syntax):

DEFINE RECORD record_name

[ OF FIXED LENGTH record_length

AS (

field_name position_specification

type_specification,

...

)

]

[ FIELD DELIMITER delimiter_char ]

[ RECORD DELIMITER delimiter_string ]

or the following (new added syntax):

AUTODEFINE RECORD record_name

[ FIELD DELIMITER delimiter_char ]

[ RECORD DELIMITER delimiter_string ]

[FIELDS PER LINE number ];

Unicode

The dbdump Data Unload and dbload Data Load utilities properly dump and load data out of a Unicode-enabled FairCom DB SQL Server. The commands file must be in ASCII format. The output file generated by dbdump is in Unicode format with an optional Byte Order Mark (BOM) indicating the Unicode encoding form (using the ‑B command-line switch).

The input file for dbload needs to be in Unicode (native "wchar" encoding form) with an optional BOM, in which case the utilities check for the proper format.

See Also

TOCIndex