Scroll to navigation

isql(1) unixODBC manual pages isql(1)

NAME

isql, iusql - unixODBC interactive SQL command-line tools

SYNOPSIS

isql DSN [USER [PASSWORD]] [options]

iusql DSN [USER [PASSWORD]] [options]

iusql "ConnectionString" [options]

DESCRIPTION

isql and iusql are command-line tools allowing users to execute SQL interactively or in batches.

The tools provide several useful features, including an option to generate output wrapped in an HTML table.

iusql is the same as isql but includes built-in Unicode support. Some data sources only work with iusql. An important difference between the two tools is that isql connects using SQLConnect and iusql connects using SQLDriverConnect.

ARGUMENTS

The Data Source Name (DSN) used to connect to the SQL database. unixODBC looks for the specified DSN in /etc/odbc.ini and $HOME/.odbc.ini, with the latter taking precedence.

When searching the configuration files, unixODBC looks for a bare name. If the DSN begins with a semicolon, it is treated as a connection string. The connection string can contain a DSN and/or other semicolon-separated parameters.

Specifies the database user or role under which the connection should be made.

This parameter overrides any UID specified in the data source configuration files.

Password required to access the database for the specified USER.

This parameter overrides any PASSWORD specified in the data source configuration files.

When using iusql, passwords containing semicolons should be escaped with braces (curly brackets) and terminated with a semicolon. Refer to the Examples section below for syntax.

"ConnectionString"
A connection string starting with DSN=, DRIVER= or FILEDSN= will be passed unchanged to SQLDriverConnect. This option allows for the use of more complex syntax in a connection string than would otherwise be possible by just using DSN, UID and PWD.

It also (and this was the main reason for its inclusion) allows passwords to contain semicolons without having to add complex escape syntax to the existing code.

OPTIONS

Run 'isql' in non-interactive batch mode. In this mode, 'isql' processes from standard input, expecting one SQL command per line.

Delimit columns with the specified delimiter.

Delimit columns with the character represented in hexadecimal by HEX. The hexadecimal code must be in the format 0xNN (e.g. 0x09 for the TAB character).

Format the result as an HTML table.

Output the names of the columns on the first row. This option can only be used with the -d or -x options.

Limit the column display width to NUM characters.

Set the character locale to LOCALE.

Wrap the character fields in double quotes.

-3
Use calls from ODBC version 3.

Process multiple lines of SQL, terminated with the GO command.

Use SQLExecDirect instead of Prepare.

Use SQLDriverConnect.

Enable verbose mode, fully describing all errors. This option is useful for debugging.

Display the program version.

Set the maximum number of characters displayed from a character field to NUM. The default value is 300 characters.

COMMANDS

This section briefly describes some isql and iusql run-time commands.

help

List all tables in the database.

help table

List all columns in the table.

help help

List all help options.

EXAMPLES

$ iusql WebDB MyID MyPWD -w -b < My.sql

Connects to the WebDB DSN as user MyID with password MyPWD, then executes the commands in the My.sql file and returns the results wrapped in an HTML table.

Each line in My.sql must only contain one SQL command, except for the last line, which must be blank (unless the -n option is specified).

Note the leading semicolon on the connection string.

$ iusql ";DSN=WebDB" MyID MyPWD -w -b < My.sql

Options in the DSN may be overridden in the connection string:

$ iusql ";DSN=WebDB;Driver=PostgreSQL ODBC;UID=MyID;PASSWORD=secret;Debug=1;CommLog=1" -v

A string DSN may be provided in its entirety, with no file DSN reference at all:

$ iusql ";Driver=PostgreSQL Unicode;UID=MyID;PASSWORD=secret" -v

$ iusql WebDB MyID '{My;PWD};'

$ iusql 'DSN=WebDB;UID=MyID;PWD={My;PWD};'

TROUBLESHOOTING

Re-run isql or iusql with the -v flag to get more information from errors, and/or enable Trace mode in odbcinst.ini.

Check that the driver name specified by the Driver entry in the odbc.ini data-source definition is present in odbcinst.ini and exactly matches the odbcinst.ini [section name].

If the ODBC driver is properly specified for the data source, it is possible that the driver is not loadable. Check for mix-ups between Unicode and ANSI drivers, and verify the driver paths in the odbcinst.ini [section name].

Some data sources are Unicode-only and require the use of iusql. If isql reports


[IM002][unixODBC][Driver Manager]Data source name not found and no default driver specified
[ISQL]ERROR: Could not SQLConnect
but the data source and driver required are listed by

odbcinst -q -d
and

odbcinst -q -s
then try iusql.

FILES

/etc/odbc.ini

Configuration file containing system-wide Data Source Name (DSN) definitions. See odbc.ini(5) for more information.

$HOME/.odbc.ini

Configuration file containing user-specific Data Source Name (DSN) definitions. See odbc.ini(5) for more information.

SEE ALSO

unixODBC(7), odbcinst(1), odbc.ini(5)

"The unixODBC Administrator Manual (HTML)"

AUTHORS

The authors of unixODBC are Peter Harvey <pharvey@codebydesign.com> and Nick Gorham <nick@lurcher.org>.

For a full list of contributors, refer to the AUTHORS file.

COPYRIGHT

unixODBC is licensed under the GNU Lesser General Public License. For details about the license, see the COPYING file.

Thu 14 Jan 2021 version 2.3.12