I have a couple of follow up questions on this.

sqlite3 doesn't seem to recognise the foreign_keys PRAGMA.  If I execute
"PRAGMA foreign_keys=1", I don't get an error.  If I then execute "PRAGMA
foreign_keys" to get the setting, nothing is returned.  If I INSERT a
record that violates the foreign key constraint, it is inserted without an
error.

Enabling foreign keys in my application works fine and INSERTs thast
violate a fkey constraint fail.  Is this a know problem with sqlite3?  I'm
using version 3.6.12 on a Mac.

Also, it appears that the foreign_keys setting only applies for the life of
a db connection and they have to be enabled every time a db is opened.  Is
that correct?  Do all PRAGMA settings work like that?

Thanks,

Pete

On Mon, Apr 2, 2012 at 9:00 AM, <sqlite-users-requ...@sqlite.org> wrote:

> Message: 12
> Date: Mon, 02 Apr 2012 15:33:20 +0700
> From: Dan Kennedy <danielk1...@gmail.com>
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] Foreign Key Problems
> Message-ID: <4f796450.9030...@gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> On 04/02/2012 07:22 AM, Pete wrote:
> > I'm running into an issue with foreign keys where no matter what value I
> > supply for a child key, I get a foreign key mismatch error.  Here are my
> > test tables.
>
> "foreign key mismatch" indicates a schema problem. Usually a missing
> index. See here:
>
>   http://www.sqlite.org/foreignkeys.html#fk_indexes
>
> It's likely you need to create a UNIQUE index on t1.RefColumn.
>



-- 
Pete
Molly's Revenge <http://www.mollysrevenge.com>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to