From SQLite documentation for CREATE TABLE http://www.sqlite.org/lang_createtable.html:
A table created using CREATE TABLE AS has no PRIMARY KEY and no
constraints of any kind.
So is there any general way to create table with primary key & other index information ?
Best Answer
I suspect you're missing the difference between
CREATE TABLE
andCREATE TABLE AS
(otherwise known as CTAS).CREATE TABLE AS
allows you to create a table from the resultset of a query.For example:
You could, instead of using CTAS, use a "normal"
CREATE TABLE
statement, thenINSERT
the rows manually. This allows you to specify thePRIMARY KEY
and any constraints. eg:Obviously, you can also create indexes etc too:
Hope that helps!