db

send SQL queries to a database via ODBC 

Command


SYNOPSIS

db [-l]

db [-eint] [-c column-sep] [-d dsn] [-u username] [-p password] [-f query-file] [-timeout seconds] [query...]


DESCRIPTION

The db command sends Structured Query Language (SQL) queries to a database via the Open Database Connectivity (ODBC) interface. db reads SQL queries from the command line or from a file, and writes the results to standard output.

Options

-c column-sep 

specifies an alternative column separator. By default, db uses the tab character as the column separator.

-d dsn 

specifies a data source name to connect to. If this option is not specified, db brings up a dialog prompting you for connection information.

-e 

exits immediately on error. Normally db continues to process SQL queries even after an error has occurred.

-f query-file 

specifies a file to read SQL queries from. If this option is not specified, and no queries are specified on the command line, db reads queries from standard input.

-i 

displays additional information about the data source name.

-l 

lists the available data source names.

-n 

does not buffer output.

-p password 

specifies a password used to connect to the data source name specified via the -d option. If this option is not specified, db prompts you for a password.

-t 

displays the names of all tables in the database.

-timeout seconds 

specifies the number of seconds that db has to complete the operation before timing out and issuing an error.

-u username 

specifies a user name used to connect to the data source name specified with the -d option.


DIAGNOSTICS

Possible exit status values are:

0 

Successful completion.

1 

An ODBC error occurred.

2 

A usage error occurred.


PORTABILITY

Windows 8.1. Windows Server 2012 R2. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022.


LIMITS

The maximum length for a SQL command (read from either a file or the command line) is 8192 characters.

The maximum amount of data which db can extract from a column is 256 characters, which corresponds to a SQL char255 field.


NOTES

To use db, you must have the ODBC 2.0 Driver Manager (or later) installed.


AVAILABILITY

PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


PTC MKS Toolkit 10.4 Documentation Build 39.