Linux command
isql 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Connect to data source
isql [dsn_name]
Connect with credentials
isql [dsn_name] [username] [password]
Connect with verbose error output
isql -v [dsn_name]
Run in batch mode (no headers)
isql -b [dsn_name] < [query.sql]
Use custom column delimiter
isql -d, [dsn_name]
Output as HTML table
isql -w [dsn_name]
Use column headers with tab delimiter
isql -b -c -x0x09 [dsn_name]
说明
isql is an ODBC command-line SQL client included with unixODBC. It connects to any database with an ODBC driver using a DSN configured in odbc.ini, and executes SQL queries interactively or from a script piped on standard input. Built-in runtime commands include `help` (list tables), `help <table>` (list columns), and `quit` to exit the session.
参数
- -v
- Verbose mode with full error descriptions.
- -b
- Batch mode (no headers, no prompts).
- -d _DELIMITER_
- Column delimiter character (e.g., -d, for comma).
- -x _HEX_
- Column delimiter as a hex code (e.g., -x0x09 for TAB).
- -c
- Output column names on first row (use with -d or -x).
- -m _NUM_
- Limit column display width to NUM characters.
- -w
- Format output as HTML table.
- -n
- Use newline processing (multi-line SQL terminated with GO).
- -e
- Use SQLExecDirect instead of Prepare.
- -k
- Use SQLDriverConnect (DSN-less connection strings).
- -l _LOCALE_
- Set locale.
- -3
- Use ODBC 3 calls.
- -L _NUM_
- Maximum characters per field (default: 300).
- -q
- Wrap character fields in double quotes.
- --version
- Print version and exit.
FAQ
What is the isql command used for?
isql is an ODBC command-line SQL client included with unixODBC. It connects to any database with an ODBC driver using a DSN configured in odbc.ini, and executes SQL queries interactively or from a script piped on standard input. Built-in runtime commands include `help` (list tables), `help <table>` (list columns), and `quit` to exit the session.
How do I run a basic isql example?
Run `isql [dsn_name]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -v do in isql?
Verbose mode with full error descriptions.