Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - Database Administration » Database Administration Utilities

Initialization utility (dbinit) Next Page

Interactive SQL utility (dbisql)


Executes SQL commands and runs command files against a database.

Syntax

dbisql [ options ] [ dbisql-command | command-file ]

Option Description
@data

Use this option to read in options from the specified environment variable or configuration file. See Using configuration files.

If you want to protect passwords or other information in the configuration file, you can use the File Hiding utility to obfuscate the contents of the configuration file. See File Hiding utility (dbfhide).

-c "keyword=value; ..."

Specify connection parameters. If Interactive SQL cannot connect, you are presented with a dialog where you can enter the connection parameters. See Connection parameters.

-codepage codepage

Specify the codepage to use when reading or writing files. The default code page is the default code page for the platform you are running on.

For example, on an English Windows XP computer, windowed programs use the 1252 (ANSI) code page. If you want Interactive SQL to read files created using the 297 (IBM France) code page, specify the following option.

-codepage 297

The default codepage for Interactive SQL can also be set using the default_isql_encoding option. You can also select the codepage when issuing an INPUT, OUTPUT, or READ statement by specifying the ENCODING clause.

For more information, see

-d delimiter

Specify a command delimiter. Quotation marks around the delimiter are optional, but are required when the command shell itself interprets the delimiter in some special way.

This option overrides the setting of the command_delimiter option. See command_delimiter option [Interactive SQL].

-d1 Interactive SQL echoes all statements explicitly executed by the user to the command window (STDOUT). This can provide useful feedback for debugging SQL scripts, or when Interactive SQL is processing a long SQL script. (The final character is a number 1, not a lowercase L). This option is available in command prompt mode only.
-datasource DSN-name Specify an ODBC data source to connect to.
-f filename Open (but do not run) the file called filename. The file name can be enclosed in quotation marks, and must be enclosed in quotation marks if the file name contains a space. If the file does not exist, or if it is really a directory instead of a file, Interactive SQL prints an error message to the console and then quits. If the file name does not include a full drive and path specification, it is assumed to be relative to the current directory.
-host hostname Specify the hostname or IP address of the computer on which the database server is running. You can use the name localhost to represent the current computer.
-nogui

Run Interactive SQL in a command-prompt mode, with no windowed user interface. This is useful for batch operations. If you specify either dbisql-command or command-file, then -nogui is assumed.

In this mode, Interactive SQL sets the program exit code to indicate success or failure. On Windows operating systems, the environment variable ERRORLEVEL is set to the program exit code. See Software component exit codes.

-onerror { continue | exit } Controls what happens if an error is encountered while reading statements from a command file. This option overrides the on_error setting. It is useful when using Interactive SQL in batch operations. See on_error option [Interactive SQL].
-port port-number Specify the port number on which the database server is running. The default port number for SQL Anywhere is 2638.
-q

Do not display output messages. This is useful only if you start Interactive SQL with a command or command file. Specifying this option does not suppress error messages, but it does suppress the following:

  • warnings and other non-fatal messages

  • the printing of result sets

-x

Scan commands but do not execute them. This is useful for checking long command files for syntax errors.

For detailed descriptions of SQL statements and Interactive SQL commands, see SQL Language Elements.

-ul

Interactive SQL customizes the options available to you depending on the type of database you are connected to. By default, Interactive SQL assumes that you are connecting to SQL Anywhere databases. When you specify the -ul option, the default changes to UltraLite databases. Regardless of the type of database set as the default, you can connect to either SQL Anywhere or UltraLite databases by choosing the database type from the dropdown list on the Connect dialog.

For more information about connecting to UltraLite databases from Interactive SQL, see Interactive SQL utility (dbisql) for UltraLite.

Remarks

Interactive SQL allows you to browse the database, execute SQL commands, and run command files. It also provides feedback about the number of rows affected, the time required for each command, the execution plan of queries, and any error messages.

You can connect to both SQL Anywhere and UltraLite databases.

The dbisql utility is supported on Windows, Solaris, Linux, and Mac OS X.

If dbisql-command is specified, Interactive SQL executes the command. You can also specify a command file name. If no dbisql-command or command-file argument is specified, Interactive SQL enters interactive mode, where you can type a command into a command window.

You can start Interactive SQL in the following ways:

Exit codes are 0 (success) or non-zero (failure). Non-zero exit codes are set only when you run Interactive SQL in batch mode (with a command line that contains a SQL statement or the name of a script file). See Software component exit codes.

Example

The following command, entered at a command prompt, runs the command file mycom.sql against the current default server, using the user ID DBA and the password sql. If there is an error in the command file, the process terminates.

dbisql -c "UID=DBA;PWD=sql" -onerror exit mycom.sql

The following command, when entered on a single line at a command prompt, adds a user to the current default database:

dbisql -c "UID=DBA;PWD=sql" GRANT CONNECT TO joe IDENTIFIED passwd