How do I DROP a constraint from a sqlite (3.6.21) table?

前端 未结 2 894
刺人心
刺人心 2020-12-05 06:26

I have the following table:

CREATE TABLE child( 
  id INTEGER PRIMARY KEY, 
  parent_id INTEGER CONSTRAINT parent_id REFERENCES parent(id), 
  description TE         


        
2条回答
  •  生来不讨喜
    2020-12-05 07:00

    I think this is an easier, more concise approach:

    copy db.sqlite3 backup-db.sqlite3
    echo .dump tablename | sqlite3 db.sqlite3 > modify.sql
    (now delete or change the constraint in modify.sql)
    echo drop table tablename; | sqlite3 db.sqlite3 
    sqlite3 db.sqlite3 < modify.sql
    

    You can now redump the new database table and compare the differences.

提交回复
热议问题