Sylar
Sylar

Reputation: 12072

Modify Sqlite Table Column NOT NULL to NULL

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".

Upvotes: 18

Views: 10722

Answers (1)

CL.
CL.

Reputation: 180020

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;

Upvotes: 37

Related Questions