(Contents)(Next)

Creating a Table

The following statement defines a table 'person':

CREATE TABLE person

(cno FIXED(4), - The cno is a four-digit number.

firstname CHAR(7), - The first name is seven and

name CHAR(8), the name is eight characters

long.

account FIXED(7,2))- The account contains up to five

digits for dollar and two digits

for cent amounts.

The statement has the following structure:

It consists of the keywords CREATE TABLE, followed by the table name, and (in parentheses) a list of column identifiers separated by commas. The optional PRIMARY KEY clause can be used to define whether a primary key is assigned to the table (a detailed description of the primary key concept is given in Section 'Accessing Single Rows'); or referential integrity constraints are defined (see Section Relations between Tables).

Each column is identified by

- the column name,

- the data types FIXED, FLOAT, CHAR (BYTE), VARCHAR, LONG, DATE, TIME, TIMESTAMP or BOOLEAN or some less usual types that are mapped to the types specified so far, or a domain name (see Section Creating Domains),

- an optional column restriction defined as CONSTRAINT and NOT NULL,

- an optional default value which is automatically entered into the column when the user does not specify an explicit value for the column.

Temporary Tables

A temporary table is a special kind of table. Temporary tables only exist during the session of a user and are deleted afterwards. They are denoted by TEMP that precedes their name.


(Contents)(Next)