HPlogo Up and Running with ALLBASE/SQL: HP 3000 and HP 9000 Computer Systems > Chapter 3 Setting Up a Database with ISQL

Creating Tables

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

Now get ready to create some tables for MUSICDBE. Before doing this step, you need to analyze the data that is to be stored. In the next paragraphs, assume that, using the suggestions in chapter 2, you have already arrived at the following table design:

Albums Table

AlbumCode

INTEGER NOT NULL

AlbumTitle

VARCHAR(40)

Medium

CHAR(2)

AlbumCost

DECIMAL(6,2)

RecordingCo

CHAR(10) NOT NULL

DateRecorded

DATE

MfgCode

VARCHAR(40)

Comment

VARCHAR(80)

Titles Table

AlbumCode

INTEGER NOT NULL

Selection

VARCHAR(40) NOT NULL

Timing

INTERVAL

Composer

VARCHAR(40)

Performers

VARCHAR(40)

Comment

VARCHAR(80)

Now, you need to create each of these tables.

Creating the Albums Table

Use the following statement to create the Albums table:

   isql=> CREATE PUBLIC TABLE Albums Return

   > (AlbumCode INTEGER NOT NULL, Return

   > AlbumTitle VARCHAR(40) NOT NULL, Return

   > Medium CHAR(2), Return

   > AlbumCost DECIMAL(6,2), Return

   > RecordingCo CHAR(10) NOT NULL, Return

   > DateRecorded DATE, Return

   > MfgCode VARCHAR(40), Return

   > Comment VARCHAR(80)) Return

   > IN ALBUMFS; Return

Did the statement complete without errors? If not, did you do the following:

  • Use a semicolon at the end?

  • Include a final close parenthesis?

  • Use valid data types and sizes?

Use the ISQL REDO command to examine and correct your SQL statement, then issue it again. (For help with REDO, type HELP REDO at the isql=> prompt.

When the statement completes without errors, use the COMMIT WORK statement to make it permanent.

NOTE: You created the Albums table as a PUBLIC table, which means that other users of the DBEnvironment need no special authorization to access the table.

Creating the Titles Table

Now, create the second table:

   isql=> CREATE PUBLIC TABLE Titles Return

   > (AlbumCode INTEGER NOT NULL, Return

   > Selection VARCHAR(40) NOT NULL, Return

   > Composer CHAR(40), Return

   > Timing INTERVAL, Return

   > Performers VARCHAR(40), Return

   > Comment VARCHAR(80)) Return

   > IN ALBUMFS; Return

If the statement completes without errors, use the COMMIT WORK statement.

[sql1001]