高级SQL特性

主键 PRIMARY KEY;

外键 REFERENCES;

检查约束 CHECK()

CREATE TABLE Orders
(
order_num INTEGER NOT NULL PRIMARY KEY,
order_date DETETION NOT NULL CHECK(quantity > 0),
cust_id CHAR(10) NOT NULL 
REFERENCES customers (cust_id)
);

 

ALTER TABLE Ordrs
ADD CONSTRAINT
FOREIGN KEY (cust_id) REFERENCES Customers (cust_id)

 

索引

CREATE INDEX prod_name_ind
ON Products (prod_name);

 

posted @ 2019-07-10 11:45  xjyxp01  阅读(174)  评论(0编辑  收藏  举报