问题信息
请登录之后查看
邀请回答
暂无人订阅该标签,敬请期待~~
墨值悬赏
sqlite 指定外键后,这个字段可以为空。
# 先打开外键
sqlite> PRAGMA foreign_keys;
0
sqlite> PRAGMA foreign_keys = ON;
sqlite> PRAGMA foreign_keys;
1
# 测试
create table t1 (id int primary key not null);
create table t2 (id int, pid int, name int, foreign key (pid) references t1(id) on delete no action on update no action);
insert into t1 select 1;
insert into t2 select 1,1,1;
insert into t2 select 1,null,1;
sqlite> select * from t2;
1|1|1
1||1
评论
有用 0
墨值悬赏