Lukas wrote:
> PRAGMA foreign_keys = ON;
>
> create table a ( id int primary key );
> create table b ( id int primary key );
> create table c ( id int primary key,
>                  aid int,
>                  bid int,
>                  foreign key (aid) references a (id) on delete cascade,
>                  foreign key (bid) references b (id) on delete cascade );
>
> insert into a values(1);
> insert into b values(1);
> insert into c values(1,1,1);
>
> drop table a;
> drop table b;
>
> Why is "drop table a" possible? It breaks the schema.

Because SQLite does not check whether it breaks the schema.  You could
recreate it, and everything would be fine.

> Why is "drop table b" causing the exception "Error: no such table:
> main.a" and what is the meaning of this message?

Before the table itself is dropped, all rows are deleted.  This requires
cascading the deletions them to c, but table c is broken because of the
missing table a.


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

Reply via email to