0

Here is a screenshot from SQLiteStudio:

enter image description here

It seems to be able to add constraints (primary key, not null, unique, etc) to a column after the table has been created. How can I do this programatically?

qed
  • 22,298
  • 21
  • 125
  • 196
  • duplicate of [ALTER COLUMN in sqlite](http://stackoverflow.com/questions/4007014/alter-column-in-sqlite) – CL. Jun 25 '15 at 11:24

1 Answers1

0

Found out:

ALTER TABLE bim RENAME TO sqlitestudio_temp_table;

CREATE TABLE bim (CHR INTEGER, SNP TEXT PRIMARY KEY, GDIST INTEGER, BP INTEGER, AL1 TEXT, AL2 TEXT);

INSERT INTO bim (CHR, SNP, GDIST, BP, AL1, AL2) SELECT CHR, SNP, GDIST, BP, AL1, AL2 FROM sqlitestudio_temp_table;

DROP TABLE sqlitestudio_temp_table;

It's creating a new table, sort of a hack.

qed
  • 22,298
  • 21
  • 125
  • 196