skip to main content
Configuring the ODBC Client : Using Interactive SQL for ODBC : Commands for Interactive SQL (ODBC)
 

Commands for Interactive SQL (ODBC)

This section describes the commands available when using ODBCISQL.

cmdfile file_name

Reads the commands from the given command file.

connect [userID*password@]database

Connects to the given data source. The database argument is the ODBC DSN entry. The userID and password are required when connecting to a server which requires userID and password. For example, the memory data source requires userID and password. The program supports only one connection at any instance. If the data source is currently connected to a different server, the connection is closed before the new connection is established.

describe "sql_stmt";

Obtains detailed schema information for query results. In the following example, this command returns a summary of column names, data types, and other results.

ISQL> DESCRIBE "SELECT CURDATE() as Today"
icol, szColName, *pcbColName, *pfSqlType, *pcbColDef, *pibScale, *pfNullable 1,
Today, 9, SQL_TYPE_DATE=91, 10, 0, SQL_NULLABLE=1
If the SQL statement is not a query, this command reports that there are no columns to describe.
This command can also be used to get schema details of a table. In this case, along with reporting the column data, the command returns information about the indexes of the table as well as table statistics, such as row count.

disconnect

Disconnects from the data source.

echo information

Echoes the given information.

errfile file_name

Errors are written to the file_name file.

# [comment]

Ignores the text following the pound sign. This is useful when OAISQL is set up to run automated test scripts that can be documented with comment lines. Note that if the -e option is enabled, the comment will be echoed to the standard out.

exec sql_stmt; or !sql_stmt;

Executes the given SQL statement. The SQL statement can be entered on multiple lines and must be terminated by a semicolon.

sql_smt;

Executes only the supported set of SQL statements. This command supports the following DML statements (SELECT, INSERT, UPDATE, DELETE, CALL) and DDL statements (CREATE TABLE, DROP TABLE). The SQL statement can be entered on multiple lines and must be terminated by a semicolon.

show/list tables;

Provides a list of all the available tables and their information as shown in the following example:

ISQL> SHOW Tables
"TABLE_CAT", "TABLE_SCHEM", "TABLE_NAME", "TABLE_TYPE", "REMARKS"
"SCHEMA", "OAUSER", "EMP", "TABLE", "Employee Table"

exit

Ends the interactive SQL session after closing any active connection.

help

Provides online help for the supported commands.

quit

Ends the interactive SQL session after closing any active connection.

repeat number command 1 … end

Repeats the given commands for the specified number of times. Any supported command can be repeated, except another repeat command.

command n timer start

Starts the timer. Any previous timer operation will be reset.

timer stop

Stops the recently started timer and reports the number of seconds elapsed.

resfile {file_name}

Logs the results to the specified file. If the file name is not specified, the command logs the results to standard output.

wait num_of_secs

Waits for the specified number of seconds.

Autocommit [on | off]

Turns on/off auto commit mode.

commit

Writes pending changes to the database.

rollback

Rolls back changes to the database.

customconnect

Connects with a custom connect string, using the following syntax:

Customconnect "Driver=name;Database=name; connect_string=value; type=value; schema_path=value;UID=userid;PWD=password"

ncmdfile file_name

Reads the Unicode commands from the given command file. The command file must be in UTF-8 format.

querytimeout num_of_secs

Query timeout for the specified number of seconds.
The default is 0. There is no timeout.

maxrows num_of_rows

Truncates rowset at the specified number of rows. The default is 100.