TurboSQL Guide

CREATE TABLE

Previous  Top  Next


Creates a new table within the current database.

Syntax

CREATE TABLE table_reference
[LEVEL level_number]
[ENCRYPTION encryption_algorithm [PASSWORD password]]
[LANGUAGE language]
(column_definition | constraint_definition [, column_definition | constraint_definition] ...)

where a column_definition looks like this:

column_reference data_type [NOT NULL] [DEFAULT expression]

(see column data types for detailed information)

and a constraint_definition like this:

PRIMARY KEY (column_reference [, column_reference]...) |
UNIQUE (column_reference [, column_reference]...) |
[CONSTRAINT constraint_name] CHECK (search_condition) |
FOREIGN KEY (column_reference [, column_reference]...)
REFERENCES table_reference (column_reference [, column_reference]...)
[ON UPDATE NO ACTION | CASCADE]
[ON DELETE NO ACTION | CASCADE]

Description

Use the CREATE TABLE command when you want to add a new table to the database.

CREATE TABLE MyTable (
OrderNo AUTOINC,
OrderId CHAR(20) NOT NULL,
Customer LINK('Customer') NOT NULL,
OrderDate DATE NOT NULL DEFAULT Today,
Destination ENUM(Home, Office, PostBox),
PRIMARY KEY(OrderNo),
CHECK(LEN(OrderId) > 3),
FOREIGN KEY(Customer) REFERENCES Customer(CustNo) ON DELETE CASCADE ON UPDATE NO ACTION
)

To define a password, a key and a language, add the appropriate keywords:

CREATE TABLE MyTable
ENCRYPTION 'Blowfish' PASSWORD 'u(i,iUklah'
LANGUAGE 'ENU'
(Name CHAR(20))

The encryption algorithms currently supported are described in "Data Security". If an encryption algorithm is given, the password must be indicated as well.
The level number is used for backward compatibility. If it is omitted the most current table format will be created.

The other clauses have their standard SQL meaning. Note that TurboSQL does not yet support the set null and the set default actions for the foreign key present in the SQL standard.

Compatibility Information

The LANGUAGE clause is not supported by TurboDB Managed.

See also

Column Data Types