NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
C-151
Examples—CREATE TABLE
Examples—CREATE TABLE
The following example creates a table named ORDERS on subvolume
$VOL1.SALES. The catalog also resides on subvolume $VOL1.SALES and the
primary key is the ORDERNUM column.
CREATE TABLE $VOL1.SALES.ORDERS (
ORDERNUM NUMERIC (6) UNSIGNED NO DEFAULT NOT NULL,
ORDER_DATE NUMERIC (6) NO DEFAULT NOT NULL,
DELIV_DATE NUMERIC (6) NO DEFAULT NOT NULL,
SALESREP NUMERIC (4) UNSIGNED NO DEFAULT NOT NULL,
CUSTNUM NUMERIC (4) UNSIGNED NO DEFAULT NOT NULL,
PRIMARY KEY ORDERNUM
)
CATALOG $VOL1.SALES;
The following example creates a table with two columns: JOBCODE and
JOBDESC. The table is key-sequenced, and the primary key is JOBCODE.
JOBCODE cannot contain null values because it is used in the primary key.
CREATE TABLE \SYS1.$VOL1.PERSNL.JOB (
JOBCODE DECIMAL (4) UNSIGNED NO DEFAULT,
JOBDESC VARCHAR (18) NO DEFAULT,
PRIMARY KEY JOBCODE )
CATALOG \SYS1.$VOL1.PERSNL ORGANIZATION KEY SEQUENCED;
The following example creates a table with column headings. The EMP table
contains three columns, EMPNUM, EMPNAME, and SALARY, that are assigned
the headings “Employee/Number,” “Employee Name,” and “Monthly Salary,
respectively. The primary key is EMPNUM.
CREATE TABLE EMP (
EMPNUM DEC(5) NO DEFAULT NOT NULL
HEADING "Employee/Number",
EMPNAME CHAR(30) UPSHIFT NO DEFAULT
HEADING "Employee Name",
SALARY DEC(8,2) DEFAULT SYSTEM
HEADING "Monthly Salary", PRIMARY KEY EMPNUM );