LinuxCommandLibrary

isql

Run interactive SQL queries against databases

SYNOPSIS

isql -v [-b] [-g] [-n] [-L] [-x] [-X] [-w ] [-s ] [-m ] [-e] [-p] [-q ] [-i ] [-o ] [-a ] [-t ] [-u ] [-P ] [-S ]

PARAMETERS

-v
    Prints the isql version number and exits.

-b
    Suppresses the display of the banner during startup.

-g
    Suppresses the display of column headings in the output.

-n
    Removes the row number when outputting query results.

-L
    Lists the available servers from the sql.ini file.

-x
    Disables exit message.

-X
    Force 'chain on' behavior.

-w
    Sets the output width to the specified value. Default is 80.

-s
    Specifies the column separator character. Default is a space.

-m
    Sets the maximum number of characters to display in each column. Default is no limit.

-e
    Echoes the input queries to the output.

-p
    Prints performance statistics.

-q
    Executes the specified query and exits.

-i
    Reads queries from the specified input file.

-o
    Redirects the output to the specified output file.

-a
    Sets the network packet size.

-t
    Sets the login timeout in seconds.

-u
    Specifies the username to use for the database connection.

-P
    Specifies the password to use for the database connection.

-S
    Specifies the server address to connect to. Can include port number.

-d
    Specifies the database to connect to.

DESCRIPTION

isql is a command-line utility that provides an interactive SQL terminal for communicating with Microsoft SQL Server and Sybase databases via the FreeTDS library. It allows users to execute SQL queries, stored procedures, and other database commands directly from the Linux terminal. isql is a crucial tool for database administrators and developers who need to interact with these databases without a graphical user interface.

It supports various options for connecting to the database, including specifying the server address, port, username, password, and database name. It also handles character set conversions to ensure proper data display. isql provides a simple yet effective way to manage and query SQL Server and Sybase databases from the Linux command line. The FreeTDS library handles the network communication and the TDS protocol details, enabling isql to work with different versions of SQL Server and Sybase.

CAVEATS

Password supplied as parameter may be visible to other users on the system via command-line tools such as `ps`. It's recommended to use environment variables or prompts to store/provide password.

SQL COMMANDS

Within the isql interface, you can use SQL commands to interact with the database. Common commands include SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, and ALTER. Consult your database server's documentation for a complete list of available commands and their syntax.

CONFIGURATION

isql relies on the `freetds.conf` file for server connection information. This file allows you to define aliases for servers, specify character sets, and configure other connection parameters. The location of `freetds.conf` is usually `/etc/freetds/freetds.conf` or `$HOME/.freetds.conf`.
It can also use `/etc/sql.ini` or `$SYBASE/sql.ini`

HISTORY

isql is a part of the FreeTDS project, an open-source implementation of the Tabular Data Stream (TDS) protocol. TDS is the protocol used by Microsoft SQL Server and Sybase databases. FreeTDS and thus isql were developed to enable Linux and Unix systems to communicate with these databases. It has been widely used for connecting applications to SQL Server from non-Windows platforms for many years. Development is ongoing with regular bug fixes and protocol improvements.

SEE ALSO

tsql(1), odbcinst(1)

Copied to clipboard