sqlite - Why this sql query doesn't return any error? -


when run these queries:

create table university ( branch text primary key, region text, enrollment int); create table student ( sid int primary key, sname text, average int); create table apply ( sid int references student(sid), branch text references university(branch), major text, decision text);  insert apply values ( 123, 'stanford', 'cs', 'y'); 

it should return error because inserting tuple doesn't have corresponding value in reference table. when run these commands, tuple inersts successfully. what's wrong queries? dbms sqlite , i'm using sqliteman.

you should learn how enable foreign key support

quoting docs:

in order use foreign key constraints in sqlite, library must compiled neither sqlite_omit_foreign_key or sqlite_omit_trigger defined. if sqlite_omit_trigger defined sqlite_omit_foreign_key not, sqlite behaves did prior version 3.6.19 - foreign key definitions parsed , may queried using pragma foreign_key_list, foreign key constraints not enforced. pragma foreign_keys command no-op in configuration. if omit_foreign_key defined, foreign key definitions cannot parsed (attempting specify foreign key definition syntax error).

also read sqliteman constraint triggers:

there 1 more unsupported sql feature. sqlite not enforce foreign keys , not null constraints.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -