标签:rest create 表数据 prim 关于 pre unique cad ict
// 创建 author 表
create table author (id INTEGER, name char(255));
// 唯一主键才能被添加成外键。
alter table author add primary key(id);
// 创建 book 表
create table book (id INTEGER, author_id INTEGER, name char(255));
// 第一,可以直接删除 Book 表记录,Author 表数据不会受到影响。
// 第二,删除 Author 表记录,串联删除 Book 表数据。
alter table book add foreign key(author_id) references author(id) on delete cascade;
// 删除约束
alter table book drop constraint ‘book_author_id_fkey‘;
注意:一个动作声明为Set Default 但是缺省值并不能满足外键,那么动作就会失败
标签:rest create 表数据 prim 关于 pre unique cad ict
原文地址:https://www.cnblogs.com/duchaoqun/p/12851823.html