开发者

create a indexed column in sqlite

开发者 https://www.devze.com 2022-12-29 07:23 出处:网络
Can I create index on a column in the create table command in sqlite? I tried this command below in sqlite3 in Android shell. It seems to work.

Can I create index on a column in the create table command in sqlite?

I tried this command below in sqlite3 in Android shell. It seems to work.

sqlite> create table mytest (id integer indexed);
sqlite> .schema
CREATE TABLE mytest (id integer indexed);

But, in sqlite's query language specification, specifying a column to be indexed i开发者_开发知识库s not supported:

http://www.sqlite.org/lang_createtable.html

Did I miss something?

Thanks.


A separate query is needed:

CREATE INDEX mytest_id_idx ON mytest(id);

Though it sounds like you want to make the id column the auto increment primary key?

CREATE TABLE mytest(id INTEGER PRIMARY KEY);
0

精彩评论

暂无评论...
验证码 换一张
取 消