本文介绍了创建sqlite的一个索引的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以在create table命令在sqlite的一个列上创建索引?
Can I create index on a column in the create table command in sqlite?
我在Android的壳试过低于sqlite3的命令。它似乎工作。
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);
不过,SQLite中的查询语言规范,指定列索引不支持:
But, in sqlite's query language specification, specifying a column to be indexed is not supported:
http://www.sqlite.org/lang_createtable.html
我错过了什么?
感谢。
推荐答案
一个单独的查询需要的:
A separate query is needed:
CREATE INDEX mytest_id_idx ON mytest(id);
虽然这听起来像你想的 ID
列自动递增主键?
CREATE TABLE mytest(id INTEGER PRIMARY KEY);
这篇关于创建sqlite的一个索引的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!