1

Cant add foreign key constraint in sqlite ...........

laalto
  • 144,748
  • 64
  • 275
  • 293

3 Answers3

7

As of SQLite 3.6.19, SQLite supports foreign keys. You need to enable them via:

sqlite> PRAGMA foreign_keys = ON;

They are turned off by default for backwards compatibility.

See the documentation for more details.

romandas
  • 3,880
  • 6
  • 28
  • 32
1

sqlite does not enforce foreign key constraints.

Darin Dimitrov
  • 994,864
  • 265
  • 3,241
  • 2,902
-1

in sqlite 3 : examples :

create table student (_id integer autoincrement primary key ,master_id integer);
create table master (_id integer autoincrement primary key , name varchar(30) );

select * from student where master_id in (select _id from master where name like '...')

Don not need foreign key (master_id) references master(_id) ; :)

Ladislav Mrnka
  • 355,666
  • 57
  • 651
  • 662
thang
  • 1