I can't comprehend! I downloaded the two packs in c:\test. Three files were 
unpacked: sqlite3.exe, sqlite3.dll and sqlite3.def.

I created the database:

c:> sqlite3 test.db

I create the structure:

sqlite> .read test.sql

The test.sql contains the statements mentioned before.

I tried to insert a further illegal record:

sqlite> insert into people(name, cities_id) values('Pedro', 14);

The record is added without problems!

I tried:

select sqlite_version();

The answer is:

3.6.21

I had placed the three files in the current folder, but to make sure old 
versions in the environment paths don't be enabled by accident, I removed 
another version in c:\windows. I don't have reasons to believe the version I 
downloaded is currently working. In the folder, I have:

test.sql

test.db

sqlite3.dll

sqlite3.exe

sqlite3.def

Unfortunately, the answer didn't change and the record follows being added 
contrarily the foreign key constraint.



----- Original Message ----- 
From: "Jean-Christophe Deschamps" <j...@q-e-d.org>
To: "General Discussion of SQLite Database" <sqlite-users@sqlite.org>
Sent: Sunday, January 03, 2010 2:51 PM
Subject: Re: [sqlite] Foreign key support in Sqlite


>
>>create table cities
>>(
>>id integer primary key not null,
>>name text not null
>>);
>>
>>create table people
>>(
>>id integer primary key not null,
>>name text not null,
>>cities_id integer not null,
>>foreign key(cities_id) references cities(id)
>>);
>>
>>insert into cities(name) values('Campos');
>>insert into cities(name) values('Araraquara');
>>insert into cities(name) values('Porto');
>>insert into cities(name) values('Curitiba');
>>insert into people(name, cities_id) values('John', 3);
>>insert into people(name, cities_id) values('Mary', 2);
>>
>>Regarding cities don't have the Id = 8, this statement should fail:
>>insert into people(name, cities_id) values('Pedro', 8);
>
> This last insert fails here (3.6.21) with constraint violation.
>
> Can you check which version you're actually running:
>
> select sqlite_version();
> 3.6.21
>
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users 

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to