SQLite Forum

Bug?: CREATE TABLE with unsatisfied FK and DROP TABLE results in Error
Login
The error message is generated because somewhere else you issued :
```sql
PRAGMA foreign_keys=on;
```
, possibly by setting SQLITE\_DEFAULT\_FOREIGN\_KEYS=1 during compilation or by including it in ~/.sqliterc .

What you see here is that the existence of the parent table "table" is not checked during CREATE TABLE, but is properly checked during any ather action, like INSERT or DROP.
This behavior is likely necessary to allow tables referencing each other in both ways, or to allow self-referencing tables.

In some cases, [foreign key checks can be postponed](https://sqlite.org/foreignkeys.html#fk_deferred) until COMMIT. Note the remark on PRAGMA defer_foreign_keys.

~~~
-- 
Regards,
Kees Nuyt
~~~