QDB Client

Execute SQL statements on QDB databases

Synopsis:

qdbc [-a scope] [-B] [-d database] [-f format] [-m] [-q] [-S] [-t timeout] 
     [-v[v...]] [-V] [-x [data@]routine] [-X [data@]routine] [sql]

Options:

-a scope
Set the scope of operation for the -B, -S, and -V options. This can be one of:
  • default — act on attached databases as specified in the configuration object (honoring the value of the VacuumAttached, BackupAttached, and SizeAttached parameters). This gives backward-compatible behavior.
  • all — always act on any attached databases, regardless of configuration object settings.
  • none — act only on the connected database itself, never on any attached databases.
-B
Perform a backup (the equivalent of calling qdb_backup()). The scope of this operation is determined by the configuration object for the database specified by -d or QDBC_DBNAME, or by the -a option, if specified.
-d database
The database you want to execute the SQL statement or other operation on. If this isn't specified, the value of the QDBC_DBNAME environment variable is used.
-f format
Format for the output. If this option isn't specified, the simple format is used by default. Can be one of:
  • simple — plain text, including column names, with field data separated by a pipe character (|); this is the default setting
  • html — HTML-encoded text
  • sgml — SGML-encoded text
  • data — plain text, without column names, with field data separated by a tab character
-m
Log memory statistics to the slog2info log. This option tells the QDB service to write memory usage information but doesn't trigger regular logging of such information. To output more memory statistics later, you must again call qdbc with this option set.
For details about the exact information logged, see the qdb_logmemstats() description.
-q
Reset verbosity to quiet mode.
-S
Print the database size information (the equivalent of calling qdb_getdbsize()) for the database specified by -d or QDBC_DBNAME. The scope of this operation is determined by the database configuration object or the -a option, if specified.
-t timeout
Set the database connection timeout, in milliseconds.
-v[v...]
Increase verbosity. You can set up to seven -v options.
-V
Perform a vacuum operation (the equivalent of calling qdb_vacuum()). The scope of this operation is determined by the configuration object for the database specified by -d or QDBC_DBNAME, or by the -a option, if specified.
-x [data@]routine
Change the configuration of a user-defined collation sequence. All collation setup functions expect data in the same format as you would specify it through qdb_collation(). For example, -x en_US@cldr would name the cldr collation routine and invoke its setup function, passing in the en_US string as the configuration data.
Note that the data portion of the argument is optional; specifying a -x argument without data lets you set the configuration of a collation to its default setting.
-X [data@]routine
Same as -X, except that database indexes are updated.
sql
An SQL statement you want to run on the specified database. This statement should be quoted and end in a semicolon. If no SQL statement is specified, qdbc enters interactive mode and takes input from the command line.

Description:

The QDB Client (qdbc) utility allows you to execute SQL statements on a QDB database without having to write code. It also allows you to perform backup, vacuum, and size query operations.

The following options are mutually exclusive, so you can specify only one:
  • -B
  • -m
  • -S
  • -V
  • -x or -X
  • sql

This means that no SQL code can be executed by qdbc when any of these listed options is used, because each option either changes the database configuration based on new collation data, or it performs a database operation that doesn't involve executing SQL code.

If you don't use any of these particular options and also don't provide an SQL command, qdbc enters interactive mode, giving you a command prompt. In this mode, you can enter as many consecutive SQL statements as you want. Statements entered in interactive mode don't need to be enclosed in quotation marks but must end in semicolons. When you are finished entering SQL statements, press CtrlC to exit.

Whether you issue an SQL command on the command line or in interactive mode, qdbc displays the result of the statement in the standard output, as long as the -q option is not set. You can also redirect a file containing SQL statements as input to qdbc:

qdbc < sql.txt