isql
Run interactive SQL queries against databases
SYNOPSIS
isql [DSN] [UID] [PWD] [options]
PARAMETERS
DSN
Data Source Name from odbc.ini (required unless using -S)
UID
Database username
PWD
Database password
-v
Verbose mode: print extra connection and query info
-b
Batch mode: suppress column headers and dashes
-d
Set output field delimiter (default '|')
-s
Set column separator (default '|')
-w
Set output line width
-n
Use newlines as column delimiters
-q
Quiet mode: suppress banner and prompts
-x
XML output format
-W
Wrap result strings in double quotes
-Q
Wrap column names in double quotes
-H
HTML table output
-e
Echo input SQL commands
-k "
Connection attributes (e.g., charset=UTF8)
-L
List available databases
-l
List available tables
-t
Display table contents
-S
Direct server connection (bypasses DSN)
-D
Initial catalog/database to use
-I
Path to custom odbc.ini file
-C
Enable cursor mode for multi-row fetches
-?
Display help
DESCRIPTION
The isql command is a command-line interactive SQL shell provided by the unixODBC package. It allows users to connect to ODBC-compliant databases, execute SQL queries, and retrieve results directly from the terminal. Designed for database administrators and developers, it supports connecting via a Data Source Name (DSN) configured in odbc.ini and odbcinst.ini files.
Upon invocation, isql prompts for SQL statements, which are sent to the specified database server. Results are displayed in a formatted table or raw output, depending on options. It supports standard SQL syntax and database-specific features through the ODBC driver. Common use cases include quick ad-hoc queries, testing ODBC connections, data inspection, and scripting via batch mode.
Key features include verbose logging for troubleshooting, customizable delimiters for output parsing, listing available databases or tables, and quiet mode for scripting. It handles transactions implicitly but supports SQL commands like COMMIT and ROLLBACK. Output can be suppressed or formatted for CSV-like exports, making it ideal for automation.
isql is lightweight, cross-platform compatible within unixODBC ecosystems, and essential for environments lacking graphical tools like DBeaver or phpMyAdmin.
CAVEATS
Requires unixODBC drivers installed and DSN configured; passwords may be visible in process lists; limited to ODBC-supported databases; no persistent sessions across invocations; potential encoding issues with non-UTF8 data.
INTERACTIVE USAGE
Enter SQL; use \q to quit; \h for help; \g or ; to execute.
EXIT CODES
0: success; 1: connection/query error; 2: usage error; 3: no data.
HISTORY
Developed as part of unixODBC project starting in 1999 by Nick van den Bleek. Evolved with ODBC 2.x/3.x standards support, key releases include unixODBC 2.3.x (2010s) adding XML/HTML output and improved scripting. Widely used in enterprise Linux distros like RHEL/CentOS for legacy DB access.
SEE ALSO
iusql(1), odbcinst(1), dltest(1), SQLGetInfo(1)


