isql

Description

Interactive SQL parser to Adaptive Server. This utility is available in the $SYBASE/$SYBASE_OCS/bin directory.

Syntax

isql [-b] [-e] [-F] [-n] [-p] [-v] [-W] [-X] [-Y] [-Q]
[-a display_charset]
[-A packet_size]
[-c cmdend]
[-D database]
[-E editor]
[-h header] 
[-H hostname]
[-i inputfile] 
[-I interfaces_file] 
[-J client_charset]
[-K keytab_file]
[-l login_timeout]
[-m errorlevel] 
[-MLabelName LabelValue]
[-o outputfile] 
[-P password] 
[-R remote_server_principal]
[-s col_separator] 
[-S server_name]
[-t timeout]
[-U username] 
[-V [security_options]]
[-w column_width] 
[-x trusted.txt_file]
[-y sybase_directory]
[-z localename] 
[-Z security_mechanism]
[--conceal [':?' | 'wildcard']]
[--help]
[--retserverror]

Parameters

-a display_charset

Allows you to run isql from a terminal where the character set differs from that of the machine on which isql is running. Use -a in conjunction with -J to specify the character set translation file (.xlt file) required for the conversion. Use -a without -J only if the client character set is the same as the default character set.

NoteThe ascii_7 character set is compatible with all character sets. If either the Adaptive Server’s or client’s character set is set to ascii_7, any 7-bit ASCII character is allowed to pass between client and server unaltered. Other characters produce conversion errors. Character set conversion issues are covered more thoroughly in the Adaptive Server Enterprise System Administration Guide.

-A packet_size

Specifies the network packet size to use for this isql session. For example, the following sets the packet size to 4096 bytes for the isql session:

isql -A 4096

To check your network packet size, enter:

select * from sysprocesses

The value is displayed under the network_pktsz heading.

packet_size must be between the values of the default network packet size and maximum network packet size configuration variables, and must be a multiple of 512.

Use larger-than-default packet sizes to perform I/O-intensive operations, such as readtext or writetext operations.

Setting or changing Adaptive Server’s packet size does not affect remote procedure calls’ packet size.

-b

Disables the display of the table headers output.

-c cmdend

Resets the command terminator. By default, you can terminate commands and send them to Adaptive Server by typing “go” on a line by itself. When you reset the command terminator, do not use SQL reserved words or control characters. Make sure to escape shell meta-characters such as , ? ( ) [ ] $ and so on.

-D database

Selects a database in which the isql session begins.

-e

Echoes input.

-E editor

Specifies an editor other than your default editor (such as vi). To invoke it, enter its name as the first word of a line in isql.

-F

Enables the FIPS flagger. When you specify the -F parameter, the server returns a message when it encounters a non-standard SQL command. This option does not disable SQL extensions. Processing completes when you issue the non-ANSI SQL command.

-h header

Specifies the number of rows to print between column headings. The default prints headings only once for each set of query results.

-H hostname

Sets the client host name.

-i inputfilename

Specifies the name of an operating system file to use for input to isql. The file must contain command terminators (“go” by default).

  • Specifying the parameter as follows is equivalent to < inputfile:

    -i inputfile
    
  • If you use -i and do not specify your password on the command line, isql prompts you for it.

  • If you use < inputfile and do not specify your password on the command line, you must specify your password as the first line of the input file.

-I interfaces_file

Specifies the name and location of the interfaces file to search when connecting to Adaptive Server. If you do not specify -I, isql looks for an interfaces file, interfaces located in the Sybase release directory.

-J client_charset

Specifies the character set to use on the client. -Jclient_charset requests that Adaptive Server convert to and from client_charset, the character set used on the client. A filter converts input between client_charset and the Adaptive Server character set.

-J with no argument sets character set conversion to NULL. No conversion takes place. Use this if the client and server use the same character set.

Omitting -J sets the character set to a default for the platform. The default may not necessarily be the character set that the client is using. For more information about character sets and the associated flags, see the Adaptive Server Enterprise System Administration Guide.

-K keytab_file

Used only with DCE security. It specifies a DCE keytab file that contains the security key for the user name specified with -U option. Keytab files can be created with the DCE dcecp utility. See your DCE documentation for more information.

If the -K option is not supplied, the bcp user must be logged in to DCE with the same user name as specified with the -U option.

-l login_timeout

Specifies the maximum timeout value allowed when connecting to Adaptive Server. The default is 60 seconds. This value affects only the time that isql waits for the server to respond to a login attempt. To specify a timeout period for command processing, use the -t timeout parameter.

-m errorlevel

Customizes the error message display. For errors of the severity level specified or higher only the message number, state, and error level display; no error text appears. For error levels lower than the specified level, nothing appears.

-M LabelName LabelValue

(secure SQL server only) enables multilevel users to set the session labels for the bulk-copy. Valid values for LabelName are:

  • curread (current read level) is the initial level of data that you can read during this session. curread must dominate curwrite.

  • curwrite (current write level) is the initial sensitivity level that will be applied to any data that you write during this session.

  • maxread (maximum read level) is the maximum level at which you can read data. This is the upper bound to which you as a multilevel user can set your curread during the session. maxread must dominate maxwrite.

  • maxwrite (maximum write level) is the maximum level at which you can write data. This is the upper bound to which you as a multilevel user can set your curwrite during a session. maxwrite must dominate minwrite and curwrite.

  • minwrite (minimum write level) is the minimum level at which you can write data. This is the lower bound to which you as a multilevel user can set curwrite during a session. minwrite must be dominated by maxwrite and curwrite.

LabelValue is the actual value of the label, expressed in the human-readable format used on your system (for example, “Company Confidential Personnel”).

-n

Removes numbering and the prompt symbol (>) from echoed input lines in the output file when used in conjunction with -e.

-o output_filename

Specifies the name of an operating system file to store the output from isql. Specifying the parameter as -o outputfile is similar to > outputfile.

-p

Prints performance statistics.

-P password

specifies your current Adaptive Server password. This option is ignored if -V is used. Passwords are case sensitive and can be from 6 to 30 characters in length. If your password is NULL, use -P without any password.

-Q

Provides clients with failover (HA) property. See the Adaptive Server Enterprise Using Sybase Failover in a High Availability System for more information.

-R remote_server_principal

Specifies the principal name for the server. By default, a server’s principal name matches the server’s network name (which is specified with the -S option or the DSQUERY environment variable). Use -R when the server’s principal name and network name are not the same.

-s colseparator

Resets the column separator character, which is blank by default. To use characters that have special meaning to the operating system (for example, “|”, “;”, “&”, “<“, “>”), enclose them in quotes or precede them with a backslash.

The column separator appears at the beginning and the end of each column of each row.

-S server

Specifies the name of the Adaptive Server to connect to. isql looks this name up in the interfaces file. If you specify -S with no argument, isql looks for a server named SYBASE. If you do not specify -S, isql looks for the server specified by your DSQUERY environment variable.

-t timeout

Specifies the number of seconds before a SQL command times out. If you do not specify a timeout, a command runs indefinitely. This affects commands issued from within isql, not the connection time. The default timeout for logging into isql is 60 seconds.

-U username

Specifies a login name. Login name is case sensitive.

-V security_options

Specifies network-based user authentication. With this option, the user must log in to the network’s security system before running the utility. In this case, users must supply their network user name with the -U option; any password supplied with the -P option is ignored.

-V can be followed by a security_options string of key-letter options to enable additional security services. These key letters are:

  • c – Enable data confidentiality service

  • d – Enable credential delegation and forward the client credentials to the gateway application

  • i – Enable data integrity service

  • m – Enable mutual authentication for connection establishment

  • o – Enable data origin stamping service

  • q – Enable out-of-sequence detection

  • r – Enable data replay detection

-v

Prints the version and copyright message of the isql and then exits.

-w columnwidth

sets the screen width for output. The default is 80 characters. When an output line reaches its maximum screen width, it breaks into multiple lines.

-W

Specifies that if the server to which isql is attempting to connect supports neither normal password encryption nor extended password encryption, plain text password retries are disabled. If this option is used, the CS_SEC_NON_ENCRYPTION_RETRY connection property will be set to CS_FALSE, and plain text (unencrypted) passwords will not be used in retrying the connection.

-x trusted.txt_file

Specifies an alternate trusted.txt file.

-X

Initiates the login connection to the server with client-side password encryption. isql (the client) specifies to the server that password encryption is desired. The server sends back an encryption key, which isql uses to encrypt your password, and the server uses the key to authenticate your password when it arrives.

This option can result in normal or extended password encryption, depending on connection property settings at the server. If CS_SEC_ENCRYPTION is set to CS_TRUE, normal password encryption is used. If CS_SEC_EXTENDED_ENCRYPTION is set to CS_TRUE, extended password encryption is used. If both CS_SEC_ENCRYPTION and CS_SEC_EXTENDED_ENCRYPTION are set to CS_TRUE, extended password encryption is used as the first preference.

If isql crashes, the system creates a core file that contains your password. If you did not use the encryption option, the password appears in plain text in the file. If you used the encryption option, your password is not readable.

-y sybase_directory

Sets an alternate Sybase home directory.

-Y

Tells the Adaptive Server to use chain transactions.

-z localename

The official name of an alternate language to display isql prompts and messages. Without -z, isql uses the server’s default language. Add languages to an Adaptive Server at installation, or afterward with the utility langinst or the sp_addlanguage stored procedure.

-Z security_mechanism

Specifies the name of a security mechanism to use on the connection.

Security mechanism names are defined in the libtcl.cfg configuration file located in the $SYBASE/ini directory. If no security_mechanism name is supplied, the default mechanism is used. For more information on security mechanism names, see the description of the libtcl.cfg file in the Open Client and Open Server Configuration Guide for UNIX.

--conceal [':?' | 'wildcard']

Hides your input during an isql session. The --conceal option is useful when entering sensitive information, such as passwords.

wildcard, a 32-byte variable, specifies the character string that triggers isql to prompt you for input during an isql session. For every wildcard that isql reads, isql displays a prompt that accepts your input but does not echo the input to the screen. The default wildcard is :?.

Note--conceal is silently ignored in batch mode.

For information on how to use the wildcard in an isql session, see “Using prompt labels and double wildcards in an isql session”.

--help

Displays a brief description of syntax and usage for the isql utility consisting of a list of available arguments. This same description will display in the event of a syntax error.

--retserverror

Forces isql to terminate and return a failure code when it encounters a server error of severity greater than 10. When isql encounters this type of abnormal termination, it writes the label “Msg” together with the actual ASE error number to stderr, and returns a value of “2” to the calling program. As before, isql prints the full server error message to stdout.

Examples

Example 1

Puts you in a text file where you can edit the query. When you write and save the file, you are returned to isql. The query appears; type “go” on a line by itself to execute it:

isql -Ujoe -Pabracadabra
 1>select * 
 2>from authors 
 3>where city = "Oakland" 
 4>vi 

Example 2

reset clears the query buffer. quit returns you to the operating system.

isql -U alma 
Password:
1>select * 
2>from authors 
3>where city = "Oakland" 
4>reset 
5>quit

Example 3

Creates column separators using the “#” character in the output in the pubs2 database for store ID 7896:

isql -Usa -P -s#
1> use pubs2
2> go
1> select * from sales where stor_id = “7896”
#stor_id#ord_num                #date                             #
#-------#-----------------------#---------------------------------#
#7896   #124152                 #              Aug 14 1986 12:00AM#
#7896    #234518                  #            Feb 14 1991 12:00AM#

(2 rows affected)

Example 4

Requests credential delegation and forwards the client credentials to MY_GATEWAY:

isql -Vd -SMY_GATEWAY

Example 5

In this retserverror example, isql returns “2” to the calling shell, prints “Msg 207” to stderr, and exits, when it encountered a server error of severity 16.

guest> isql -Uguest -Pguestpwd -SmyASE --retserverror
       2> isql.stderr
1> select no_column from sysobjects
2> go
Msg 207, Level 16, State 4: 
Server 'myASE', Line 1: 
Invalid column name 'no_column'.

guest> echo $?
2
guest> cat isql.stderr
Msg     207
guest>

Example 6

When you use the --help option, isql returns a brief description of syntax and usage for the isql utility consisting of a list of available arguments.

guest> isql --help
usage: isql [option1] [option2] ... where [options] are...
-b                 Disables the display of the table headers output.
-e                 Echoes input.
-F                 Enables the FIPS flagger.
-p                 Prints performance statistics.
-n                 Removes numbering and the prompt symbol when used 
                   with -e.
-v                 Prints the version number and copyright message.
-W                 Turn off extended password encryption on connection
                   retries.
-X                 Initiates the login connection to the server with
                   client-side password encryption.
-Y                 Tells the Adaptive Server to use chained transactions.
-Q                 Enables the HAFAILOVER property.
-a display_charset Used in conjunction with -J to specify the character set
                   translation file (.xlt file) required for the conversion.
                   Use -a without -J only if the client character set is the
                   same as the default character set.
-A packet_size     Specifies the network packet size to use for this isql
                   session.
-c cmdend          Changes the command terminator.
-D database        Selects the database in which the isql session begins.
-E editor          Specifies an editor other than the default editor vi.
-h header          Specifies the number of rows to print between column
                   headings.
-H hostname        Sets the client host name.
-i inputfile       Specifies the name of the operating system file to use
                   for input to isql.
-I interfaces_file Specifies the name and location of the interfaces file.
-J client_charset  Specifies the character set to use on the client.
-K keytab_file     Specifies the path to the keytab file used for
                   authentication in DCE.
-l login_timeout   Specifies the number of seconds to wait for the server
                   to respond to a login attempt.
-m errorlevel      Customizes the error message display.
-M labelname labelvalue
                   Used for security labels. See CS_SEC_NEGOTIATE for more
                   details.
-o outputfile      Specifies the name of an operating system file to store
the output from isql.
-P password        Specifies your Adaptive Server password.
-R remote_server_principal
                  Specifies the principal name for the server as defined to
                  the security mechanism.
-s col_separator  Resets the column separator character, which is blank by
                  default.
-S server_name    Specifies the name of the Adaptive Server to which to
                  connect.
-t timeout        Specifies the number of seconds before a SQL command times
                  out.
-U username       Specifies a login name. Login names are case sensitive.
-V [security_options]
                  Specifies network-based user authentication. Valid
                  [security_options]:
                  c - Enable data confidentiality service.
                  i - Enable data integrity service.
                  m - Enable mutual authentication for connection 
                      establishment.
                  o - Enable data origin stamping service.
                  q - Enable out-of-sequence detection.
                  r - Enable data replay detection.
                  d - Requests credential delegation and forwards client
                      credentials.
-w column_width   Sets the screen width for output.
-y sybase_directory 
                  Sets an alternate location for the Sybase home directory.
-z localename     Sets the official name of an alternate language to display
                  isql prompts and messages.
-Z security_mechanism
                  Specifies the name of a security mechanism to use on the
                  connection.
-x trusted.txt_file Specifies an alternate trusted.txt file location.
--retserverror    Forces isql to terminate and return a failure code when it
                  encounters a server error of severity greater than 10.
--conceal [wildcard]
                  Obfuscates input in an ISQL session. The optional wildcard
                  will be used as a prompt.

Example 7

Sets an alternate Sybase home directory using the -y option:

isql -y/work/NewSybase -Uuser1 -Psecret -SMYSERVER

Example 8

In this example of --conceal, password is modified without displaying the password entered. This example uses “old” and “new” as prompt labels:

$ isql -Uguest -Pguest -Smyase --conceal
1> sp_password
2> :? old
3> ,
4> :?:? new
5> go
old
new
Confirm new
Password correctly set.
(return status = 0)

Example 9

In this example of --conceal, password is modified without displaying the password entered. This example uses the default wildcard as the prompt label:

$ isql -Uguest -Pguest -Smyase --conceal
1> sp_password
2> :?
3> ,
4> :?:?
5> go
:?
:?
Confirm :?
Password correctly set.
(return status = 0)

Example 10

Activate a role for the current user. This example of --conceal uses a custom wildcard and the prompt labels “role” and “password”:

$ isql -UmyAccount --conceal '*'
Password:
1> set role
2> * role
3> with passwd
4> ** password
5> on
6> go
role
password
Confirm password
1>

Usage


Additional commands within isql:

Table A-5: isql session commands

Command

Description

>

Redirects command output to a file. File is overwritten if it exists.

>>

Redirects command output to a file. The output is appended to the file if the file already exists.

|

Pipes the output of a command to an external application.

reset

Clears the query buffer.

quit or exit

Exits from isql.

vi

Calls the editor.

!! command

Executes an operating system command.

:r filename

Reads an operating system file.

:R filename

Reads and displays an operating system file.

use dbname

Changes the current database to dbname.


Using prompt labels and double wildcards in an isql session

In an isql session, the default prompt label is either the default wildcard :? or the value of wildcard. You can customize the prompt label by providing a one-word character string with a maximum length of 80 characters, after a wildcard. If you specify a prompt label that is more than one word, the characters after the first word are ignored.

Double wildcards such as :?:? specify that isql needs to prompt you twice for the same input. The second prompt requests you to confirm your first input. If you use a double wildcard, the second prompt label starts with Confirm.

NoteIn an isql session, isql recognizes :? or the value of wildcard as wildcards only when these characters are placed at the beginning of an isql line.

See also

sp_addlanguage, sp_addlogin, sp_configure, sp_defaultlanguage, sp_droplanguage, and sp_helplanguage in the Adaptive Server Enterprise Reference Manual.