SQL/MX Quick Start (G06.24+, H06.03+)

Creating Database Objects
HP NonStop SQL/MX Quick Start523724-002
9-2
Creating a Table
Creating a Table
The minimum amount of information you must supply when creating a table includes:
A table name
The name and data type of each column
The name of the catalog and schema that will contain the table definition
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 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.