SQL/MX Quick Start (H06.04+, J06.03+)
Creating Database Objects
HP NonStop SQL/MX Quick Start—540438-001
9-2
Creating a Table
Creating a Table
At a minimum, when creating a table, you must supply:
•
A table name
•
The name and data type of each column
Example
Suppose you want to create a table to organize attendees of a conference into teams.
The table contains four columns. To create this table in the catalog MYCAT, enter:
CREATE TABLE MYCAT.MYSCH.MYTABLE
(EMPNUM NUMERIC (4) UNSIGNED NO DEFAULT NOT NULL,
FIRST_NAME CHARACTER (15) NO DEFAULT NOT NULL,
LAST_NAME CHARACTER (20) NO DEFAULT NOT NULL,
TEAMNUM NUMERIC (4) UNSIGNED NO DEFAULT NOT NULL,
PRIMARY KEY (EMPNUM, TEAMNUM));
--- SQL operation complete.
Tip
•
The table is created on the current default volume and subvolume. The table
contains no data, you insert data into the table as a separate operation.
•
The previous example uses the fully qualified table name with the catalog MYCAT
and the schema MYSCH preceding the table name. The SET CATALOG statement
sets the default logical catalog, and the SET SCHEMA statement sets the default
logical schema. The default catalog and schema you specify remain in effect until
the end of the session or until you execute another SET CATALOG or SCHEMA
statement.










