CREATE TABLE and KEYS
CREATE TABLE t (
cf CHAR(10) DEFAULT 'n/a' NOT NULL,
nf SMALLINT DEFAULT 0 NOT NULL,
def REPLSQL-decimal(4,2) DEFAULT 1.23 NOT NULL,
daf REPLSQL-date DEFAULT REPLSQL-dateliteral '2001-02-03' NOT NULL,
tf REPLSQL-timestamp DEFAULT REPLSQL-timestampliteral '2002-03-04 10:20:30' NOT NULL,
bf REPLSQL-boolean REPLSQL-null,
PRIMARY KEY (cf),
UNIQUE (daf)
);
CREATE INDEX foo_def_idx ON t (def);
-
Each column definition needs the following order:
name, type, default, constraint
-
Keep column names to 28 or fewer characters.
-
Don't define columns with DEFAULT '' NOT NULL due to Oracle.
-
Don't use DEFAULT clauses with Microsoft Access.
-
The TIMESTAMP, DATE, BOOLEAN, DECIMAL
and CLOB types need to be replaced depending on the DBMS.
-
Put PRIMARY KEY below the column definitions, but still inside the
CREATE TABLE statement.
-
Put UNIQUE below that. Don't name the keys.
Don't use the KEY or INDEX keywords.
-
Use separate CREATE INDEX queries for regular keys.
Name the keys.