create table t_group
(
id integer,
primary key (id)
);
create table t_user
(
id integer,
name text,
groupId integer,
primary key(id),
foreign key (groupId) references t_group(id) on delete cascade on update cascade ); insert into t_group values(1); insert into t_group values(2); insert into t_user values(1,"j",2); insert into t_user values(2,"a",3); 原文链接:https://www.f2er.com/sqlite/199309.html