The sql command invokes the line mode Terminal Monitor for SQL. For procedures on using this Terminal Monitor, see the SQL Reference Guide.
The sql command has the following format:
sql [SQL option flags] [line-mode flags] dbname |vnode::dbname[/server_class] [<altin] [>altout]
Specifies flags that can be used with the line mode Terminal Monitor and other commands where noted. The SQL option flags determine the format of output or the behavior of the DBMS. You can specify a maximum of 12 SQL option flags. The flags are as follows:
-cN
Sets the minimum field width for printing character columns to N. The default is 6.
-fkxM.N
Sets floating-point output column width to M characters (total), including N decimal places, and (if warranted) e+-xx and the decimal indicator character itself.
k can be 4 or 8 to apply to f4's or f8's respectively.
x can be E, F, G or N (uppercase or lowercase) to specify an output format. E indicates exponential format. F indicates floating-point format. G indicates the floating-point format and guarantees decimal alignment. N indicates floating-point format, decimal alignment, and right-justification.
If you specify N or G and the number is too large for the format indicated by the flag, it is displayed in exponential format. To prevent this format overflow, M should be greater than or equal to N + 7.
The default display format for both f4 and f8 is n10.3, unless your computer supports the IEEE standard for floating-point numbers, in which case the display format for f4 and f8 is n11.3.
Sets integer output column width to N. k can be 1, 2, or 4 for i1's, i2's, or i4's, respectively. The default for N is 6 for i1 and i2 fields, and 13 for i4 fields.
-tN
Sets the minimum field width for printing text columns to N. The default is 6.
+U|-U
Enables (+U) or disables (-U) user updating of the system catalogs and secondary indexes, and takes an exclusive lock on the database. To update system catalogs, you must have the update system tables privilege obtained through accessdb.
On VMS, enclose this flag in double quotation marks ("+U" or "-U").
+Y|-Y
Enables (+Y) or disables (-Y) user updating of the system catalogs and secondary indexes, but does not take an exclusive lock on the database.
On VMS, enclose this flag in double quotation marks ("+Y" or "-Y").
Specifies the effective user for the session, as described in Standard Flags and Parameters.
-Ggroupid
Specifies a group identifier, as described in Standard Flags and Parameters.
On VMS, enclose this flag in double quotation marks ("-Ggroupid").
-Rroleid
Specifies a role identifier for the session, as described in Standard Flags and Parameters.
On VMS, enclose this flag in double quotation marks ("-Rroleid")
-l
Locks the database for your exclusive use. When you specify this flag, no one else can open the database while you are in it. If you attempt to take an exclusive lock on a database that is in use, the system informs you that the database is temporarily unavailable.
-nM
Sets modify mode on the index command to M. M must be one of the following storage structures: ISAM, CISAM, B-tree, CB-tree, Hash, or CHash. The default is ISAM.
+w|-w
Indicates to wait (+w) or not wait (-w) for the database. The default is w. If you specify +w, you must wait if certain processes are running (sql –l, sql –U, verifydb, rollforwarddb, or sysmod) on the given database, before the operation proceeds.
If you specify –w and the database is not available, a message is returned and execution is stopped. If you omit the w flag and the database is unavailable, an error message is returned if running in foreground (more precisely, if the standard input is from a terminal). Otherwise, the wait option is invoked.
On VMS, this flag is not valid in batch mode.
Sets error handling mode for numeric overflow, underflow and division by zero.
The fail setting causes an error message to be issued and the statement is aborted. This is the default setting. To obtain ANSI-compliant behavior, use this setting (or omit for the default).
The ignore setting causes no error message to be issued.
The warn setting causes a warning message to be issued.
Sets error handling mode for string truncation errors. This error occurs if you attempt to insert a string into a table column that is too short to contain the value.
The fail setting causes an error message to be issued and the statement is aborted.
The ignore setting causes no error message to be issued. The string is truncated and inserted. This is the default setting.
Specify flags that can be used with the line mode Terminal Monitor only. The flags are as follows:
+a|-a
Sets (+a) or clears (-a) the autoclear option in the terminal monitor. The default is +a.
Prints (+d) or does not print (-d) the dayfile. The default is +d.
+s|-s
Prints (+s) or does not print (-s) the monitor messages, including prompts. The default is +s. If you specify -s, the dayfile is not displayed.
-vX
Sets the column separator to the character specified by X. The default is vertical bar (|).
-Ppassword
Specifies the user password.
-Rrole-name/role-password
Identifies the role name and optional role password. Separate the name and password with a slash (/).
-history_recall
Invokes the terminal monitor with history recall functionality, which lets you retrieve the history of commands typed in the session, and perform other functions. For details, see the SQL Reference Guide.
Specifies the name of the database, and if required, the vnode and server_class, as described in Standard Flags and Parameters.
Specifies a file from which the Terminal Monitor reads commands. The file must contain all terminal monitor commands needed to run the session. On VMS, no space is allowed between the < character and the file name.
Directs output from the Terminal Monitor to the specified file. If you specify this parameter, you will not see any output. On VMS, no space is allowed between the > character and the file name.
This command opens the SQL line mode Terminal Monitor for working in the empdata database:
sql empdata
This command opens empdata and does not print the dayfile:
sql empdata -d
This command opens empdata, suppressing the dayfile message and the terminal monitor prompts and messages, and reads into the workspace the contents of the batchfile:
sql empdata -s <batchfile
This command opens empdata, displays f4 columns in G format with two decimal places and i1 columns with three spaces:
sql empdata -f4g12.2 -I13