On 8/19/11 10:18 AM, "Boris Kolpackov" <bo...@codesynthesis.com> wrote:


>Hi William,
>
>"Duquette, William H (318K)" <william.h.duque...@jpl.nasa.gov> writes:
>
>> What if you defined the foreign key with "ON DELETE CASCADE"?  Dropping
>> the employer table will delete the employees.
>
>That would be bad for the normal use. In other words, I don't want the
>CASCADE semantics for those references and I don't think there is a way
>to globally turn this on for all the foreign keys.

There's something odd here.  You have the FK constraints deferred, and
your code looks like this:

BEGIN TRANSACTION;
DROP TABLE employer;
DROP TABLE employee;
COMMIT;

According to the sqlite docs, dropping a table when FK constraints are
enabled does an implicit "DELETE FROM" first.  That DELETE FROM is causing
the constraint violations.  But you have them deferred; they won't be
reported until the COMMIT, and only if the constraints are still violated
at that time.  But by then, you've also dropped the employee table, so how
can there still be FK constraint violations?

Am I missing something?

Are you sure you're dropping the tables in a transaction?

Will





>
>_______________________________________________
>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