1.1 创建表的可选项
CREATE MULTISET TABLE table_1
,FALLBACK, NO JOURNAL
,FREESPACE = 10 PERCENT
,DATABLOCKSIZE = 16384 BYIES
(field1 INTEGER);
1.2 字段定义
字段名:在同一数据库中必须唯一
字段或数据类型
CREATE TABLE emp_data
(employee_number INTEGER
,department_number SMALLINT
,job_code INTEGER,
,last_name CHAR(20)
,first_name VARCHAR(20)
,birthday DATE
,salary_amount DECIMAL(10,2)
CREATE TABLE emp_data
(employee_number INTEGER NOT NULL
,last_name CHAR(20) NOT NULL WITH DEFAULT
,street_address VARCHAR(30) TITLE "Address"
,city CHAR(15) DEFAULT "Boise"
,state CHAR(2) WITH DEFAULT
,birthday DATE FORMAT "mm/dd/yyyy"
,salary_amount DEC(10,2)
,sex CHAR(1) UPPERCASE
);
UPPERCASE(字母大小写不敏感,内部用大写字母存储)
CREATE TABLE emp_data
(employee_number INTEGER
,department_number INTEGER COMPRESS
);
CREATE TABLE employee_badge
(emp_id INTEGER NOT NULL
CONSTRAINT primary_1 PRIMARY KEY
,id_badge_number INTEGER
CONSTRAINT unique_1 UNIQUE
,salary INTEGER
CONSTRAINT check_1 CHECK (salary>0)
,job_code INTEGER
CONSTRAINT ref_1 REFERENCES job (job_code)【定义employee_badge的job_code必须和job表中的job_code对应】
);
1.3表级约束定义
CREATE TABLE employee_badge
(emp_id INTEGER NOT NULL
,id_badge_num INTEGER NOT NULL
,salary INTEGER
,job_code INTEGER
,CONSTRAINT primary_1 PRIMARY KEY (emp_id)
,CONSTRAINT unique_1 UNIQUE(id_badge_num)
,CONSTRAINT check_1 CHECK(salary >0 AND
job_code BETWEEN 100000 AND 499999)
,CONSTRAINT ref_1 FOREIGN KEY (job_code)
REFERENCES job(job_code));
1.4索引定义
CREATE MULTISET TABLE emp_data
,FALLBACK
,NO BEFORE JOURNAL
,NO AFTER JOURNAL
,FREESPACE = 30
,DATABLOCKSIZE = 10000 BYTES(
employee_number INTEGER NOT NULL
,department_number SMALLINT
CONSTRAINT dep_check
CHECK (department_number BETWEEN 100 AND 999)
REFERENCES Department(department_number)
,job_code INTEGER COMPRESS
,last_name CHAR(20) NOT NULL
,first_name VARCHAR(20)
,street_address VARCHAR(30) TITLE "Address"
,city CHAR(15) DEFAULT "Boise"
COMPRESS Boise
,state CHAR(2) WITH DEFAULT
,birthday DATE FORMAT 'mm/dd/yyyy'
,salary_amout DECIMAL(10,2)
,sex CHAR(1) UPPERCASE
,CONSTRAINT emp_key
PRIMARY KEY (employee_number)
)INDEX (department_number);