Wednesday, February 26, 2014

sqlite3 foreign key constraint so bad?


 
drop table t_group;
drop table t_user;


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

Why is the last one where I can use sql insert in sqlite3 success, but was intercepted in mysql?<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
From the top. . .
Reply:
sqlite3 does not support foreign keys
Themselves with trigger control
Reply:
Upstairs according achieve good
Reply:
Enter the command line PRAGMA foreign_keys = ON; ok, you can support it.

No comments:

Post a Comment