Igor Tandetnik writes:
[...]
>
> Why would you want to fail statements that end up not violating any
> constraints?
The idea is to prevent that somebody can change the table staff that is not
already in the table. Therefore I create the first user by not switching on
foreign
Oliver Peters wrote:
> Please believe me I really try hard to understand - but what I don't
> understand
> is the fact that you can insert in this case:
>
>
> PRAGMA foreign_keys = ON;
>
> /*
> **success INSERT = yes
> */
>
> CREATE TABLE a(
>id
Dan Kennedy writes:
>
> > why returns the "INSERT INTO a" not an error while the "INSERT INTO
> > b" does? How
> > corresponds this behaviour to the concept of FOREIGN KEYS?
>
> > CREATE TABLE a(
> >idINTEGER PRIMARY
> >
Am 09.08.2010 16:57, schrieb Oliver Peters:
> [...]
>
> To my mind the simplified question is:
>
> why returns the "INSERT INTO a" not an error while the "INSERT INTO b" does?
> How
> corresponds this behaviour to the concept of FOREIGN KEYS?
>
> I wrote the code into file.sql (encoding=utf8,
> why returns the "INSERT INTO a" not an error while the "INSERT INTO
> b" does? How
> corresponds this behaviour to the concept of FOREIGN KEYS?
> CREATE TABLE a(
>idINTEGER PRIMARY
> KEY
> AUTOINCREMENT,
>id_staff_editor
[...]
To my mind the simplified question is:
why returns the "INSERT INTO a" not an error while the "INSERT INTO b" does? How
corresponds this behaviour to the concept of FOREIGN KEYS?
I wrote the code into file.sql (encoding=utf8, if this matters) and started
sqlite3 -bail test.db3 <
I found the (apparent) problem.
This works and throws the constraint violation:
PRAGMA foreign_keys=OFF;
CREATE TABLE staff_01(
id INTEGER PRIMARY KEY AUTOINCREMENT,
id_staff_editor INTEGER NOT NULL,
code CHAR(2) NOT NULL,
FOREIGN KEY(id_staff_editor) REFERENCES staff(id)
);
INSERT INTO
I use the standard windows binary from http://www.sqlite.org/sqlite-3_7_0_1.zip
and if I do the recommended test I get
>sqlite3
SQLite version 3.7.0.1
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> pragma foreign_keys;
0
sqlite> pragma foreign_keys=ON;
sqlite>
On 9 August 2010 14:56, Black, Michael (IS) wrote:
> From http://www.sqlite.org/foreignkeys.html
>
>
>
> Although I believe I compiled my shell WITHOUT these defined but I still
> don't get enforcement of the foreign key constraint.
>
> It appears that foreign keys are
>From http://www.sqlite.org/foreignkeys.html
Although I believe I compiled my shell WITHOUT these defined but I still don't
get enforcement of the foreign key constraint.
It appears that foreign keys are fully constrained by default. Is there any
way in the shell to find out if it's
Igor Tandetnik writes:
>
> Oliver Peters wrote:
> > This sql code works in the two cases but AFAIK it shouldn't in the second
> >
> > PRAGMA foreign_keys = ON;
> >
> > CREATE TABLE staff_02(
> > idINTEGER PRIMARY KEY
Oliver Peters wrote:
> This sql code works in the two cases but AFAIK ;-) it shouldn't in the second
>
> PRAGMA foreign_keys = ON;
>
> CREATE TABLE staff_02(
> idINTEGER PRIMARY KEY AUTOINCREMENT,
> id_staff_editor INTEGER
and the added , after UNIQUE(code) doesn't change anything
(oh what a day ;-) )
Oliver
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
13 matches
Mail list logo