|
|
Up and Running with ALLBASE/SQL: HP 3000 and HP 9000 Computer Systems > Chapter 3 Setting Up a Database with ISQLEntering Data into Tables |
|
Once you have created tables, you can get data into them in several ways. Try the following two methods:
Use the SQL INSERT statement to add rows to the tables you have created. Try the following entry for the Albums table:
If the statement does not complete successfully, check all your punctuation carefully, and try again. When finished, COMMIT WORK. Next, use the INSERT statement to add the following row to the Titles table (you need to build the INSERT statement yourself):
Note that INSERT is an SQL statement that processes a single row of data at a time. If you want to insert many rows at a time, use an application program of your own design, or else try the ISQL LOAD command, explained below. Use the ISQL LOAD command to insert data from an ordinary file into your tables. Two kinds of LOAD operation are possible:
The next sections show an example of each.
You use the LOAD command with the INTERNAL option to load data from a file in INTERNAL format previously created by ISQL's UNLOAD command. Your system contains an INTERNAL file with data for the Titles table. In MPE/iX, it is called TITLE.SAMPLEDB.SYS; in HP-UX, it is called /usr/lib/allbase/hpsql/sampledb/title. From ISQL, issue the appropriate command for your system: On MPE/iX:
On HP-UX:
As loading progresses, messages tell you how many rows have been processed.
Use the LOAD command with the EXTERNAL option to load data from plain ASCII files into a table. You must enter the names of the columns in the table you are loading into and the starting location in the file where each data item starts, together with the data item's length. If the column permits null values, the data file must contain null indicator characters for any entry that is null. In the following example, the question mark (?) is used as a null indicator. From ISQL, issue one of the following commands, as appropriate for your system. Be sure to type exactly. On MPE/iX:
On HP-UX:
After you have entered the column descriptions, ISQL prompts you as follows:
Reply N to load all the values in the file. When the command completes, issue a COMMIT WORK statement:
Note that the starting columns for each field of data are determined by the actual position of the data in the file itself. Thus, using EXTERNAL files, it is possible to load selected parts of each record. For complete information about loading tables from INTERNAL and EXTERNAL files, refer to the ALLBASE/ISQL Reference Manual. |
|