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> ... ?
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> ... ?
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:
CREATE TABLE child2 (
id INTEGER PRIMARY KEY,
parent_id INTEGER,
description TEXT
);
INSERT INTO child2 (id, parent_id, description)
SELECT id, parent_id, description FROM CHILD;
DROP TABLE child;
ALTER TABLE child2 RENAME TO child;
You could also leave out parent_id from all the statements above if you don't want it transferred.