17

I am looking for something similar to this but I'm using sqlite3. I have tried:

sqlite> UPDATE JOBS SET JOB_TYPES = NULL;

But I got "constraint failed". Am I doing it the correct way?

I want to change the current "NOT NULL" to "NULL".

Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
Sylar
  • 11,422
  • 25
  • 93
  • 166

1 Answers1

36

SQLite has almost no ALTER TABLE support.

The easiest method to change a table is to create a new table, and copy the data over:

CREATE TABLE Jobs2(..., JOB_TYPES NULL, ...);
INSERT INTO Jobs2 SELECT * FROM Jobs;
DROP TABLE Jobs;
ALTER TABLE Jobs2 RENAME TO Jobs;
CL.
  • 173,858
  • 17
  • 217
  • 259