I have the following table:
CREATE TABLE child(
id INTEGER PRIMARY KEY,
parent_id INTEGER CONSTRAINT parent_id REFERENCES parent(id),
description TEXT);
How do I drop the constraint?
I have the following table:
CREATE TABLE child(
id INTEGER PRIMARY KEY,
parent_id INTEGER CONSTRAINT parent_id REFERENCES parent(id),
description TEXT);
How do I drop the constraint?
SQLite does not support the
alter table drop constraint
command. You will need to create a new table without a constraint, transfer the data, then delete the old table.I think something like the following should work:
Note that the
insert into
could probably be simplified to not use explicit column names but I've left it that way in case you want to change the structure as well.For example, if you're removing the constraint on the
parent_id
column, it's of dubious use to keep it there at all. In that case, you could modify the data transfer to:I think this is an easier, more concise approach:
You can now redump the new database table and compare the differences.