高级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);

猜你喜欢

转载自www.cnblogs.com/xjyxp/p/11162957.html