| Firebird Documentation Index → Isql - Interactive SQL → Using Isql Interactively |
![]() |
The Firebird isql utility can be used interactively to:
Create, update, query, and drop data and meta data.
Add and modify data.
Test queries.
Perform database administrative functions.
Input a script file containing a batch of SQL statements in sequence without prompting.
To perform these functions, isql accepts three kinds of commands at the prompt:
DDL statements: Data Definition Language statements are used to define database schemas and/or objects. Examples of DDL commands include: CREATE, ALTER, RECREATE and DROP.
DML statements: Data Manipulation Language statements allow the user to manipulate data objects and relationships between them, in the context of given database schemas. DML supports the manipulation and processing of database objects. Examples of DML statements are: INSERT, UPDATE and DELETE.
Isql commands, which are instructions to isql itself, including SET and SHOW commands. These are discussed below.
Commands that perform general tasks, such as processing scripts and executing shell commands. These commands are: INPUT, OUTPUT, QUIT, SHELL, BLOBDUMP, BLOBVIEW, HELP, EDIT, ADD, COPY and EXIT.
INPUT: reads and executes SQL scripts from a defined text file. These files can have several embedded DDL scripts in them. Scripts, can be created using a text editor or built interactively, using the OUTPUT or EDIT command. For example:
SQL> INPUT filename;
Table 3. INPUT arguments
| ARGUMENTS | DESCRIPTIONS |
|---|---|
| FILENAME | Name of a file containing SQL statements and commands. |
OUTPUT: redirects output to a disk file or to a monitor(output screen). To output both data and commands, use SET ECHO ON. To output data only, use SET ECHO OFF. Here is the code:
SQL> OUTPUT [filename];
Table 4. OUTPUT arguments
| ARGUMENTS | DESCRIPTIONS |
|---|---|
| FILENAME | Name of the file where output is saved. If no file name is given, results appear on the monitor. |
Example:
SQL> OUTPUT C:\data\managers.dta; SQL> SELECT EMP_NO, EMP_NAME FROM MANAGER; /* Output goes to file */ SQL> OUTPUT; /* Output goes back to screen */
SHELL: provides temporary access to the command line of the operating system shell without committing or rolling back any transactions. Here is the code:
SQL> SHELL [operating system command];
Table 5. SHELL arguments
| ARGUMENTS | DESCRIPTIONS |
|---|---|
| Operating System command | A valid operating system command or call. After the command is executed, control returns to isql. In cases where no command is issued, isql opens an interactive session in the OS shell. To return control to isql, type exit. |
Example :
SQL> SHELL dir /mydir;
BLOBDUMP: stores BLOB(Binary Large Object) data in a defined file. Here is the code:
SQL> BLOBDUMP blob_id filename;
Table 6. BLOBDUMP arguments
| ARGUMENTS | DESCRIPTIONS |
|---|---|
| BLOB ID | Identifier consisting of two hex numbers separated by a colon (:). The first number is the ID of the table containing the BLOB column, the second is a sequenced instance number. To get the blob_id, issue any SELECT statement that selects a column of BLOB data. The output will show the hex blob_id above or in place of the BLOB column data, depending on whether SET BLOB[DISPLAY] is ON or OFF. |
| FILENAME | Fully qualified file system name of the file which is to receive the data. |
Example :
SQL> BLOBDUMP 32:d48 IMAGE.JPG;
BLOBVIEW: BLOBVIEW displays BLOB data in the default text editor. Here is the code:
BLOBVIEW blob_id;
Table 7. BLOBVIEW arguments
| ARGUMENTS | DESCRIPTIONS |
|---|---|
| BLOB ID | Identifier consisting of two hex numbers separated by a colon (:). See BLOBDUMP for instructions on how to determine the blob_id you are looking for. In current versions, BLOBVIEW does not support online editing of the BLOB. It may be introduced in a future release. |
| FILENAME | Fully qualified file system name of the file which is to receive the data. |
Example :
SQL> BLOBVIEW 85:7;BLOBVIEW may return an “Invalid transaction handle” error after you close the editor. This is a known bug. To correct the situation, start a transaction manually, with the command SET TRANSACTION;
HELP: displays a list of isql commands with descriptions. You can combine it with OUTPUT to print the list to a file. Here is the code:
SQL> HELP;
For example, to create a text file containing all the output from the help command:
SQL> OUTPUT HELPLIST.TXT; SQL> HELP; SQL> OUTPUT; /* toggles output back to the monitor */
No arguments.
EDIT: allows editing and re-execution of the previous isql command or of a batch of commands in a source file. Here is the code:
SQL> EDIT [filename];
Table 8. EDIT arguments
| ARGUMENT | DESCRIPTION |
|---|---|
| FILENAME | Optional, fully qualified file system name of file to edit. |
Example :
SQL> EDIT /usr/mystuff/batch.sql;
ADD: adds rows interactively to a table, field after field.
COPY: copies the structure of a table into a new table, either in the same database or in another.
EXIT: commits the current transaction without prompting, closes the database and ends the isql session.
If you need to rollback the transaction instead of committing it, use QUIT instead.
Example :
SQL> EXIT;
No arguments.
QUIT: rolls back the current transaction without prompting, closes the database and ends the isql session.
If you need to commit the transaction instead of rolling it back, use EXIT instead.
Example :
SQL> QUIT;
No arguments.
SHOW COMMANDS: are used to query the database to display meta data. Meta data is stored in system tables. Meta data includes the definition of database objects such as domains, generators, tables, constraints, indices, views, triggers, stored procedures, user-defined functions(UDFs), and blob filters. SHOW commands run in READ COMMITTED mode to ensure the return of the most up-to-date view of the database. Here is the list of SHOW commands:
SHOW DOMAIN[S]: displays domain information. A domain is a user-defined data type, global to the database. It is used to define the format and range of columns, upon which the actual column definitions in tables are based.
Firebird tables are defined by the specification of columns, which store appropriate information in each column using data types.
A data type is an elemental unit when defining data, which specifies the type of data stored in tables, and which operations may be performed on this data. It can also include permissible calculative operations and maximum data size. Examples of data types include: numerical (numeric, decimal, integer);textual (char, varchar, nchar, nvarchar); date (date, time, timestamp) and blobs(binary large objects).
Here is the syntax to display domain information:
SQL> SHOW { DOMAINS | DOMAIN name };
Table 9. SHOW DOMAIN[S] arguments
| ARGUMENTS | DESCRIPTION |
|---|---|
| DOMAIN[S] | Lists the names of all the domains declared in the database |
| DOMAIN name | Displays definition of the named domain |
Example :
SQL> SHOW DOMAIN;
ADDRESSLINE BUDGET
COUNTRYNAME CUSTNO
DEPTNO EMPNO
FIRSTNAME JOBCODE
...
SQL> SHOW DOMAIN ADRESSLINE;
ADDRESSLINE VARCHAR(30) NullableSHOW GENERATOR[S}: displays information about generators. Generators are automatic sequential counters, spanning the entire database. They are outside the purview of transaction control. Here is the syntax to display generator information:
SQL> SHOW { GENERATORS | GENERATOR name };
Table 10. SHOW GENERATOR[S] arguments
| ARGUMENTS | DESCRIPTION |
|---|---|
| GENERATORS | Lists the names of all generators declared in the database, along with their next values |
| GENERATOR NAMES | Displays the declaration of the named generator, along with its next value |
Example :
SQL> SHOW GENERATORS; Generator CUST_NO_GEN, current value is 1015 Generator EMP_NO_GEN, current value is 145 SQL> SHOW GENERATOR EMP_NO_GEN; Generator EMP_NO_GEN, current value is 145
The term generator is non standard and has been replaced by the ANSI Standard term sequence. The above should now be replaced by the following:
SQL> SHOW SEQUENCES; Generator CUST_NO_GEN, current value is 1015 Generator EMP_NO_GEN, current value is 145 SQL> SHOW SEQUENCE EMP_NO_GEN; Generator EMP_NO_GEN, current value is 145
SHOW CHECK: displays all user-defined check constraints defined for a table. Here is the syntax for the code:
SQL> SHOW CHECK <table name>;
Table 11. SHOW CHECK arguments
| ARGUMENTS | DESCRIPTION |
|---|---|
| Table Name | Name of a table that exists in the attached database, and if it has any user-defined check constraints |
Example :
SQL> SHOW CHECK COUNTRY; There are no check constraints on table COUNTRY in this database
SHOW DATABASE: displays information about the attached database (file name, page size and allocation, sweep interval, transaction numbers and Forced Writes status) and starting in Firebird 2.0, also reveals the On-Disk Structure or ODS version.
On-Disk structure or ODS identifies a database with the release version of Firebird. The ODS of a database affects its compatibility with server versions. The ODS can be upgraded by using the gbak utility. In Firebird 2.0 ODS has been changed to 11.
For version, see SHOW VERSION. Here is the syntax for the code:
SQL> SHOW DATABASE | DB;
No arguments.
Example :
SQL> SHOW DATABASE;
Database: C:\Databases\Firebird\employee.fdb
Owner: SYSDBA
PAGE_SIZE 4096
Number of DB pages allocated = 259
Sweep interval = 20000
Forced Writes are ON
Transaction - oldest = 179
Transaction - oldest active = 180
Transaction - oldest snapshot = 180
Transaction - Next = 187
ODS = 11.0
Default Character set: NONESHOW EXCEPTION[S]: displays exception information.
Exceptions are user-defined named error messages, written specifically for a database and stored in that database for use in stored procedures and triggers. An exception is triggered when the value in a table is ascertained to be incorrect. This leads to a rollback of the transaction that the client application is attempting to commit. Exceptions can be interleaved. They can be shared among the different modules of an application, and even among different applications sharing a database. They provide a simple way to standardize the handling of preprogrammed input errors. Here is the syntax for the code:
SQL> SHOW { EXCEPTIONS | EXCEPTION name };
Table 12. SHOW EXCEPTION[S] arguments
| ARGUMENTS | DESCRIPTION |
|---|---|
| EXCEPTIONS | Lists the names and texts of all exceptions declared in the database |
| EXCEPTION NAME | Displays text of the named single exception |
| TYPE | Stored Procedure |
Example :
SQL> SHOW EXCEPTIONS; Exception Name Used by, Type =============================== ================================= CUSTOMER_CHECK SHIP_ORDER, Stored procedure Msg: Overdue balance -- can not ship. CUSTOMER_ON_HOLD SHIP_ORDER, Stored procedure Msg: This customer is on hold. ... SQL> SHOW EXCEPTION CUSTOMER_CHECK; Exception Name Used by, Type =============================== ================================= CUSTOMER_CHECK SHIP_ORDER, Stored procedure Msg: Overdue balance -- can not ship.
SHOW FUNCTION[S]: displays information about user-defined functions (UDFs) declared in the attached database.
A user-defined function (UDF) is used to perform tasks that Firebird cannot. It can be described as an external database function written entirely in another language, such as C++ or Pascal, to perform data manipulation tasks not directly supported by Firebird.
UDFs can be called from Firebird and executed on the server. These functions can exist on their own or be collected into libraries. UDFs offer the possibility to create your own functions (such as SUBSTR) and integrate them in the database itself. Each UDF is arranged as a function, belonging to a DLL (Linux: .so). Thus one dynamically loaded library consists of at least one function.
UDF definitions are database dependent and not server dependent, i.e. they need to be registered for each database individually. Since in Firebird, the libraries need to be stored in the Firebird UDF folder. Please refer to the DECLARE EXTERNAL FUNCTION statement for details of incorporating UDFs in Firebird.
It is important to note that the majority of UDFs, when used in a WHERE condition, prevent indices from being used during execution.
Here is the syntax for the code:
SQL> SHOW { FUNCTIONS | FUNCTION name };
Table 13. SHOW FUNCTION[S] arguments
| ARGUMENTS | DESCRIPTION |
|---|---|
| FUNCTION[S] | Lists the names of all UDFs declared in the database |
| FUNCTION NAME[S] | Displays the declaration of the named UDF |
SHOW GRANT: displays privileges and ROLE ownership information about a named object in the attached database; or displays user membership within roles.
GRANT is the SQL statement, used to assign privileges to database users for specified database objects. Here is the syntax for the code:
SQL> SHOW GRANT { object | role name };
Table 14. SHOW GRANT arguments
| ARGUMENTS | DESCRIPTION |
|---|---|
| OBJECT | Name of an existing table, view or procedure in the current database |
| ROLE NAME | Name of an existing role in the current database. Use SHOW ROLES to list all the roles defined for this database. |
Example:
SQL> SHOW GRANT; ... GRANT EXECUTE ON PROCEDURE ADD_EMP_PROJ TO PUBLIC WITH GRANT OPTION GRANT EXECUTE ON PROCEDURE ALL_LANGS TO PUBLIC WITH GRANT OPTION GRANT EXECUTE ON PROCEDURE DELETE_EMPLOYEE TO PUBLIC WITH GRANT OPTION GRANT EXECUTE ON PROCEDURE DEPT_BUDGET TO PUBLIC WITH GRANT OPTION GRANT EXECUTE ON PROCEDURE GET_EMP_PROJ TO PUBLIC WITH GRANT OPTION ... SQL> SHOW GRANT ADD_EMP_PROJ; GRANT EXECUTE ON PROCEDURE ADD_EMP_PROJ TO PUBLIC WITH GRANT OPTION
SHOW INDEX | INDICES: displays information about a named index, about indices for a specified table or about indices for all tables in the attached database. Here is the syntax for the code:
SQL> SHOW {INDICES | INDEX { index | table } };
Table 15. SHOW INDEX| INDICES arguments
| ARGUMENT | DESCRIPTION |
|---|---|
| INDEX | Name of an existing index in the current database |
| TABLE | Name of an existing table in the current database |
SHOW IND is an alias for either SHOW INDEX or SHOW INDICES.
Example:
SQL> SHOW INDEX; RDB$PRIMARY1 UNIQUE INDEX ON COUNTRY(COUNTRY) CUSTNAMEX INDEX ON CUSTOMER(CUSTOMER) CUSTREGION INDEX ON CUSTOMER(COUNTRY, CITY) RDB$FOREIGN23 INDEX ON CUSTOMER(COUNTRY) RDB$PRIMARY22 UNIQUE INDEX ON CUSTOMER(CUST_NO) ... SQL> SHOW INDEX CUSTNAMEX; CUSTNAMEX INDEX ON CUSTOMER(CUSTOMER)
SHOW PROCEDURE[S]: lists all procedures in the attached database, with their dependencies; or displays the text of the named procedure with the declarations and types (input/output) of any parameters. Here is the syntax for the code:
SQL> SHOW {PROCEDURES | PROCEDURE name };
Table 16. SHOW PROCEDURE[S] arguments
| ARGUMENT | DESCRIPTION |
|---|---|
| NAME | Name of an existing stored procedure in the current database. |
SHOW PROC is an alias for either SHOW PROCEDURE or SHOW PROCEDURES.
Example:
SQL> SHOW PROCEDURE;
Procedure Name Dependency, Type
================================= ======================================
ADD_EMP_PROJ EMPLOYEE_PROJECT, Table
UNKNOWN_EMP_ID, Exception
ALL_LANGS JOB, Table
SHOW_LANGS, Procedure
...
SQL> SHOW PROCEDURE ADD_EMP_PROJ;
Procedure text:
========================================================================
BEGIN
BEGIN
INSERT INTO employee_project (emp_no, proj_id)
VALUES (:emp_no, :proj_id);
WHEN SQLCODE -530 DO
EXCEPTION unknown_emp_id;
END
SUSPEND;
END
========================================================================
Parameters:
EMP_NO INPUT SMALLINT
PROJ_ID INPUT CHAR(5)
SHOW ROLE[S]: displays the names of SQL roles for the attached database. A role is a set of privileges on a set of database objects such as tables and views. Roles are assigned using a GRANT statement. To show user membership within roles, use SHOW GRANT| ROLE NAME.
There can be a chain of roles; for example, in a bank, the role employee may be granted to all tellers, and the role of teller may be granted to all managers, in addition to all privileges automatically granted to managers. Thus all actions executed by a session have all the privileges granted directly to the user, as well as all privileges granted to roles that are granted (directly or indirectly via other roles) to that user.
Here is the syntax for the code:
SQL> SHOW ROLES;
No arguments.
SHOW SQL DIALECT: displays the SQL dialects of the client and of the attached database, if there is one. Here is the syntax for the code:
SQL> SHOW SQL DIALECT;
Example:
SQL> SHOW SQL DIALECT;
Client SQL dialect is set to: 3 and database SQL dialect is: 3SHOW SYSTEM: displays the names of system tables and system views for the attached database. Here is the syntax:
SQL> SHOW SYS [ TABLES ];
No arguments.
TABLES is an optional keyword that does not affect the behavior of the command in versions up to Firebird 1.5.3(?). This changes in version 2.0 onwards.
In Firebird Version 2.0, the SHOW SYSTEM command shows predefined UDFs. The SHOW < object_type> command is designed to show user objects of that type. In versions earlier than 2.0, the SHOW SYSTEM command showed only system tables. Starting with 2.0, it also lists predefined system UDFs. In future releases it could also display views.
Shorthand: SHOW SYS is equivalent.
Example:
SQL> SHOW SYSTEM;
Tables:
RDB$BACKUP_HISTORY RDB$CHARACTER_SETS
RDB$CHECK_CONSTRAINTS RDB$COLLATIONS
RDB$DATABASE RDB$DEPENDENCIES
RDB$EXCEPTIONS RDB$FIELDS
RDB$FIELD_DIMENSIONS RDB$FILES
...
Functions:
RDB$GET_CONTEXT RDB$SET_CONTEXTSHOW TABLES: lists all tables or views in the database, and or displays information on specific named table[s] or view[s].
Example:
SQL> SHOW TABLES;
COUNTRY CUSTOMER
DEPARTMENT EMPLOYEE
EMPLOYEE_PROJECT JOB
PROJECT PROJ_DEPT_BUDGET
SALARY_HISTORY SALESSee also SHOW VIEW[s].
SHOW TRIGGERS: displays all the triggers defined in the database along with the associated table name. A database trigger is procedural code, that is automatically executed in response to specific events, on a specified table, in a database. Here is the syntax for the code:
SQL>SHOW TRIGGERS;
Example:
SQL> SHOW TRIGGERS; Table name Trigger name =========== ============ CUSTOMER SET_CUST_NO EMPLOYEE SAVE_SALARY_CHANGE EMPLOYEE SET_EMP_NO SALES POST_NEW_ORDER
SHOW VERSION: displays information about the software versions of isql and the Firebird server program, and the on-disk structure of the attached database. However, in Firebird 2.0 onwards the ODS version can also be returned using the SHOW DATABASE statement. Here is the syntax for the code:
SQL> SHOW VERSION;
No arguments.
Shorthand: SHOW VER is equivalent.
Example:
SQL> SHOW VERSION; ISQL Version: WI-V2.0.0.12745 Firebird 2.0 Release Candidate 5 Server version: Firebird/x86/Windows NT (access method), version "WI-V2.0.0.12745 - Firebird 2.0 Release Candidate 5" Firebird/x86/Windows NT (remote server), version "WI-V2.0.0.12745 - Firebird 2.0 Release Candidate 5/XNet (PLAYTHING)/P10" Firebird/x86/Windows NT (remote interface), version "WI-V2.0.0.12745 - Firebird 2.0 Release Candidate 5/XNet (PLAYTHING)/P10" on disk structure version 11.0
The output listed above has been split over more than one line to allow it to fit on a PDF page. Hyphens show the location where certain lines have been split.
SHOW VIEW[s]: lists all views, or displays information about the named view.
Here is the syntax for the code:
SQL> SHOW { VIEWS | VIEW name };
Table 17. SHOW VIEW[S]
| ARGUMENT | DESCRIPTION |
|---|---|
| NAME | Name of an existing view in the current database. The output contains column names and the SELECT statement that the view is based on. |
Example:
SQL> SHOW VIEW;
PHONE_LISTSee also SHOW TABLES.
SET COMMANDS: enable users to view and change the isql environment. To view the current settings for the various set commands in the database, issue the following command:
SET;
SQL> SET; Print statistics: OFF Echo commands: OFF List format: OFF Row Count: OFF Autocommit DDL: ON Access Plan: OFF Access Plan only: OFF Display BLOB type: 1 Column headings: ON Terminator: ; Time: OFF Warnings: ON Bail on error: OFF
SET AUTODDL: specifies whether DDL statements are committed automatically after being executed, or committed only after an explicit COMMIT. Here is the syntax for the code:
SQL> SET AUTODDL [ON | OFF]; /* default is ON */
Table 18. SET AUTODDL arguments
| ARGUMENT | DESCRIPTION |
|---|---|
| ON | Toggles automatic commit on. |
| OFF | Toggles automatic commit off. |
Shorthand : SET AUTO (with no argument) simply toggles AUTODDL on and off.
SET BLOBDISPLAY: specifies both sub_type of BLOB to display and whether BLOB data should be displayed. Here is the syntax for the code:
SQL> SET BLOBDISPLAY [ n | ALL | OFF ];
Table 19. SET BLOBDISPLAY arguments
| ARGUMENT | DESCRIPTION |
|---|---|
| n | BLOB SUB_TYPE to display. Default: n= 1 (text) |
| ON | Display BLOB data of any sub_type |
| OFF | Toggles display of BLOB data off. The output shows only the Blob ID (two hex numbers separated by a colon (:). The first number is the ID of the table containing the BLOB column. The second is a sequenced instance number. |
Shorthand: SET BLOB is the same.
SET COUNT: toggles off/on whether to display the number of rows retrieved by queries. Here is the syntax for the code:
SQL> SET COUNT [ON | OFF];
Table 20. SET COUNT arguments
| ARGUMENT | DESCRIPTION |
|---|---|
| ON | Toggles on display of "rows returned" message |
| OFF | Toggles off display of "rows returned" message (default) |
SET ECHO: toggles off/on whether commands are displayed before being executed. Default is ON but you might want to toggle it to OFF if sending your output to a script file. Here is the syntax for the code:
SQL> SET ECHO [ON | OFF]; /* default is ON */
Table 21. SET ECHO arguments
| ARGUMENTS | DESCRIPTION |
|---|---|
| ON | Toggles on command echoing (default) |
| OFF | Toggles off command echoing |
SET NAME[s]: specifies the character set that is to be active in database transactions. Here is the syntax for the code:
SQL> SET NAMES charset;
Table 22. SET NAMES arguments
| ARGUMENTS | DESCRIPTION |
|---|---|
| CHARSET | Name of the active character set. Default: NONE |
SET PLAN: specifies whether to display the optimizer's query plan. Here is the syntax for the code:
SQL> SET PLAN [ ON | OFF ];
Table 23. SET PLAN arguments
| ARGUMENT | DESCRIPTION |
|---|---|
| ON | Turns on display of the query plan. Default. |
| OFF | Turns off display of the query plan. |
Shortcut: omit ON | OFF and use just SET PLAN as a toggle.
SET PLANONLY: specifies to use the optimizer's query plan and display just the plan, without executing the actual query. (Available in Firebird 1 and higher). Here is the syntax for the code:
SQL> SET PLANONLY ON | OFF;
The command works as a toggle switch. The argument is optional.
SET SQL DIALECT: specifies the Firebird SQL dialect to which the client session is to be changed. If the session is currently attached to a database of a different dialect to the one specified in the command, a warning is displayed. Here is the syntax for the code:
SQL> SET SQL DIALECT n;
Table 24. SET SQL DIALECT arguments
| ARGUMENT | DESCRIPTION |
|---|---|
| n | n = 1 for Dialect 1, 2 for Dialect 2, 3 for Dialect 3 |
SET STATS: specifies whether to display performance statistics following the output of a query. Here is the syntax for the code:
SQL> SET STATS [ ON | OFF ];
Table 25. SET STATS arguments
| ARGUMENT | DESCRIPTION |
|---|---|
| ON | Turns on display of performance statistics. Displays: • Current memory available (bytes)• Change in available memory (bytes) • Maximum memory available (bytes) • Elapsed time for the operation (seconds) • CPU time for the operation (seconds) • Number of cache buffers used • Number of reads requested • Number of writes requested • Number of fetches done |
| OFF | Turns off display of performance statistics. Default. |
Shortcut: omit ON | OFF and use just SET STATS as a toggle.
SET TERM: specifies the character which will be used as the command or statement terminator, from the next statement forward. Here is the syntax for the code:
SQL> SET TERM string;
Table 26. SET TERM arguments
| ARGUMENTS | DESCRIPTION |
|---|---|
| String | Character or characters which will be used as statement terminator. Default: ; |
SET TIME: specifies whether to display the time portion of a DATE value (Dialect 1 only). Here is the syntax for the code:
SQL> SET TIME [ ON | OFF ];
Table 27. SET TIME arguments
| ARGUMENTS | DESCRIPTION |
|---|---|
| ON | Toggles on time portion display in Dialect 1 DATE value |
| OFF | Toggles on time portion display in Dialect 1 DATE value. Default. |
SET TRANSACTION: To be completed.
SET WARNINGS: specifies whether warnings are to be output. A few examples for which isql issues warnings are:
SQL statement that cause no effect.
Pending database shutdown.
API calls that may be replaced in future versions of Firebird.
Here is the syntax for the code:
SQL> SET WARNINGS [ ON | OFF ];
Table 28. SET WARNINGS arguments
| ARGUMENTS | DESCRIPTIONS |
|---|---|
| ON | Toggles on display of warnings if it was toggled off, or if the session was started with the - nowarnings option. |
| OFF | Toggles off display of warnings if it is currently toggled on. |
Shorthand: SET WNG can be used as a substitute, as a simple on/off toggle.
SET HEADING[S]: This allows users to disable the printing of column headers, when doing a SELECT inside isql, and having the output sent to a file, for processing at a later stage. In versions before 2.0, isql used to print all the column headers by default, and sometimes the sheer number of columns made the display in isql impractical. This has now been fixed with the SET HEADING[s] on | off toggle.
This switch cannot be deactivated with a command line parameter. Using SET will display the state of SET HEAD, along with other switches that can be toggled on/off in the isql shell.
SET BAIL: will toggle the state between activated and deactivated. Using SET will display the state of the switch among many others. Even if BAIL is activated, it doesn't mean it will change isql. For example isql -b -i my_fb.sql -o results.log -m -m2behavior. An additional requirement should be met: the session should be non-interactive. A non-interactive session happens when the user calls isql in batch mode, giving it a script as input.
If the user loads isql interactively, and later executes a script with the input command; this is considered an interactive session, even though isql knows it is executing a script.
Example:
Use CONNECT or CREATE DATABASE to specify a database SQL> set bail; SQL> input my_fb.sql; SQL> ^Z
SET SQLDA_DISPLAY ON | OFF: The SQLDA_DISPLAY command shows the input SQLDA parameters of INSERTS, UPDATES AND DELETES. It reveals information on the raw SQLVARS. A SQLVAR represents a field in XSQLDA, the main structure used by the Firebird API to talk to clients, transferring data in and out of the server. This feature has been introduced in Firebird 2.0. It was previously available only in DEBUG builds.
As of Firebird 2.0 this feature is not yet displayed by isql when you type SET; to view the settings of options.
Isql commands affect the running of isql itself and do not affect the database or data in any way. These commands are used to display help, run scripts, create listings and so on. You can easily see a list of the available commands by typing the help command which will produce the following output:
SQL> help;
Frontend commands:
BLOBDUMP <blobid> <file> -- dump BLOB to a file
BLOBVIEW <blobid> -- view BLOB in text editor
EDIT [<filename>] -- edit SQL script file and execute
EDIT -- edit current command buffer and execute
HELP -- display this menu
INput <filename> -- take input from the named SQL file
OUTput [<filename>] -- write output to named file
OUTput -- return output to stdout
SET <option> -- (Use HELP SET for complete list)
SHELL <command> -- execute Operating System command in sub-shell
SHOW <object> [<name>] -- display system information
<object> = CHECK, COLLATION, DATABASE, DOMAIN, EXCEPTION, FILTER, FUNCTION,
GENERATOR, GRANT, INDEX, PROCEDURE, ROLE, SQL DIALECT, SYSTEM,
TABLE, TRIGGER, VERSION, USERS, VIEW
EXIT -- exit and commit changes
QUIT -- exit and roll back changes
All commands may be abbreviated to letters in CAPitals
Each of these commands will now be discussed. Note the last line of output from the help command. It explains that each of the commands may be abbreviated to just those letters displayed in capital letters. In the following discussion, the optional characters will be wrapped in square brackets. For example, the input command will be shown as in[put] to indicate that the characters 'put' are optional.
As explained in the help command, there are a number of individual show commands within isql. These are as follows:
As explained in the help command, you may enter the help set command to drill down into the various options available for the set command. These are all discussed below. Note that the output from the help set command does not include the set transaction command. The help set command produces the following output:
SQL> help set;
Set commands:
SET -- display current SET options
SET AUTOddl -- toggle autocommit of DDL statements
SET BAIL -- toggle bailing out on errors in non-interactive mode
SET BLOB [ALL|<n>] -- display BLOBS of subtype <n> or ALL
SET BLOB -- turn off BLOB display
SET COUNT -- toggle count of selected rows on/off
SET ROWCOUNT [<n>] -- limit select stmt to <n> rows, zero is no limit
SET ECHO -- toggle command echo on/off
SET HEADING -- toggle display of query column titles
SET LIST -- toggle column or table display format
SET NAMES <csname> -- set name of runtime character set
SET PLAN -- toggle display of query access plan
SET PLANONLY -- toggle display of query plan without executing
SET SQL DIALECT <n> -- set sql dialect to <n>
SET STATs -- toggle display of performance statistics
SET TIME -- toggle display of timestamp with DATE values
SET TERM <string> -- change statement terminator string
SET WIDTH <col> [<n>] -- set/unset print width to <n> for column <col>
All commands may be abbreviated to letters in CAPitals
The last line of the above output indicates that these commands can be abbreviated to the letters in capitals. Unfortunately, other than the set autoddl command, none of the others appear to have a short form.
The set command, with no parameters, displays the current settings, as the following example from Firebird 2.5 shows:
SQL> set; Print statistics: OFF Echo commands: OFF List format: OFF List Row Count: OFF Select rowcount limit: 0 Autocommit DDL: ON Access Plan: OFF Access Plan only: OFF Display BLOB type: 1 Column headings: ON Terminator: ; Time: OFF Warnings: ON Bail on error: OFF
set auto[ddl] [on | off];
This command sets whether all DDL statements executed will be automatically committed or not. The command without any parameters acts as a toggle and turns autoddl off if it is currently on and vice versa. You may supply a specific parameter to make your intentions clear. The parameter must be one of on or off. The set command, with no parameters, will display the current setting. The default in isql is equivalent to set autoddl on.
This is a hidden command which is not mentioned in the output from the help set command.
This is another hidden command which is not mentioned in the output from the help set command.
Normally the width of a character column in a table defines the width of the output when that column is selected. Using the set width command allows the user to define a wider or narrower output column width.
The format of the command is set width column_or_alias width; The setting remains until changed to a new width, or until cancelled by the set width column_or_alias; command - no width supplied means use the default width setting for this column.
The following example shows the width of the last_name column being amended. The first SELECT shows the default setting which is a wdith of 20 characters (count the '=' in the headings) which is the definition of the last_name column in the employee table. The second shows the width being reduced to 10 characters.
SQL> select first 10 emp_no, last_name
CON> from employee
CON> order by last_name;
EMP_NO LAST_NAME
======= ====================
34 Baldwin
105 Bender
28 Bennet
83 Bishop
109 Brown
SQL> set width last_name 10;
SQL> select first 10 emp_no, last_name
CON> from employee
CON> order by last_name;
EMP_NO LAST_NAME
======= ==========
34 Baldwin
105 Bender
28 Bennet
83 Bishop
109 Brown
Emp_no is a smallint data type. Unfortunately, it doesn't appear to be possible to change the width on non-character columns line integer, smallint etc. The set width emp_no 10; command, for example, has no effect, as shown below, which also demonstrates turning off a previous width setting for the last_name column:
SQL> set width last_name;
SQL> set width emp_no 10;
SQL> select first 10 emp_no, last_name
CON> from employee
CON> order by last_name;
EMP_NO LAST_NAME
======= ====================
34 Baldwin
105 Bender
28 Bennet
83 Bishop
109 Brown
| Firebird Documentation Index → Isql - Interactive SQL → Using Isql Interactively |