1.mysql
CREATE TABLE Orders
(
Id_O int NOT NULL,
OrderNo int NOT NULL,
Id_P int,
PRIMARY KEY (Id_O),
FOREIGN KEY (Id_P) REFERENCES Persons(Id_P)
)
2.外键的作用是和其他表关联起来,防止非法插入
3.如何建立级联删更新,删除呢
create table a(id int,name varchar(25));
create table b(id int,name varchar(20),constraint 'b_id' foreign key(id) references a(id)
on delete cascade on update cascade);