I created a table in Sqlite by using the CREATE TABLE AS syntax to create a table based on a SELECT statement. Now this table has no primary key b
CREATE TABLE AS
SELECT
I had the same problem and the best solution I found is to first create the table defining primary key and then to use insert into statement.
CREATE TABLE mytable ( field1 INTEGER PRIMARY KEY, field2 TEXT ); INSERT INTO mytable SELECT field1, field2 FROM anothertable;