Using interactive SQL
Interactive SQL allows a programmer or a database administrator to quickly and easily define, update, delete, or look at data for testing, problem analysis, and database maintenance.
A programmer, using interactive SQL, can insert rows into a table and test the SQL statements before running them in an application program. A database administrator can use interactive SQL to grant or revoke privileges, create or drop schemas, tables, or views, or select information from system catalog tables.
After an interactive SQL statement is run, a completion message or an error message is displayed. In addition, status messages are normally displayed during long-running statements.
You can see help on a message by positioning the cursor on the message and pressing F1=Help.
The basic functions supplied by interactive SQL are:
- The statement entry function allows you to:
- Type in an interactive SQL statement and run it.
- Retrieve and edit statements.
- Prompt for SQL statements.
- Page through previous statements and messages.
- Call session services.
- Start the list selection function.
- Exit interactive SQL.
- The prompt function allows you to type either a complete SQL statement or a partial SQL statement, press F4=Prompt, and then be prompted for the syntax of the statement. It also allows you to press F4 to get a menu of all SQL statements. From this menu, you can select a statement and be prompted for the syntax of the statement.
- The list selection function allows you to select from lists of your authorized relational databases, schemas, tables, views, columns, constraints, or SQL packages.
The selections you make from the lists can be inserted into the SQL statement at the cursor position.
- The session services function allows you to:
- Change session attributes.
- Print the current session.
- Remove all entries from the current session.
- Save the session in a source file.
- Starting interactive SQL
To start using interactive SQL, enter STRSQL from an i5/OS® command line.
- Using the statement entry function
The statement entry function is the function that you first enter when selecting interactive SQL. You return to the statement entry function after processing each interactive SQL statement.
- Prompting
The prompt function helps you provide the necessary information for the syntax of the statement that you want to use. The prompt function can be used in any of these statement processing modes: *RUN, *VLD, and *SYN. Prompting is not available for all SQL statements and is not complete for many SQL statements.
- Using the list selection function
You can access the list selection function by pressing F4 (Prompt) on certain prompt displays. To access the function on the Enter SQL Statements display, press F16 (Select collections), F17 (Select tables), or F18 (Select columns).
- Session services description
You can change session attributes from the Session Services display. You can also print, clear, or save the session to a source file.
- Exiting interactive SQL
To exit the interactive SQL environment, press F3 (Exit) on the Enter SQL Statements display. Several options are available for exiting.
- Using an existing SQL session
If you saved only one interactive SQL session by selecting option 1 (Save and exit session) on the Exit Interactive SQL display, you can resume the session at any workstation.
- Recovering an SQL session
If the previous SQL session ended abnormally, interactive SQL presents the Recover SQL Session display at the start of the next session when you enter the Start SQL Interactive Session (STRSQL) command.
- Accessing remote databases with interactive SQL
In interactive SQL, you can communicate with a remote relational database by using the SQL CONNECT statement. Interactive SQL uses the CONNECT (Type 2) semantics (distributed unit of work) for CONNECT statements.
Parent topic:
Using SQL in different environments
Related concepts
Dynamic SQL applications
Related reference
Processing non-SELECT statements