Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有办法知道SQLite内部索引在哪些列上?_Sqlite - Fatal编程技术网

有没有办法知道SQLite内部索引在哪些列上?

有没有办法知道SQLite内部索引在哪些列上?,sqlite,Sqlite,对于用户定义的索引,sqlite\u master的最后一列告诉我它们在哪些列上。但正如您所看到的,对于由(非rowid)主键和唯一键隐式创建的索引,没有此信息。是否有一种可靠的方法可以让我判断哪个自动索引是哪个?内部索引和显式创建的索引之间没有区别;您可以使用相同的PRAGMAs(,)获取有关它们的信息: sqlite>pragma索引列表(foo); seq name唯一来源部分 ---------- ---------------------- ---------- --------

对于用户定义的索引,
sqlite\u master
的最后一列告诉我它们在哪些列上。但正如您所看到的,对于由(非rowid)
主键和
唯一键隐式创建的索引,没有此信息。是否有一种可靠的方法可以让我判断哪个
自动索引是哪个?

内部索引和显式创建的索引之间没有区别;您可以使用相同的PRAGMAs(,)获取有关它们的信息:

sqlite>pragma索引列表(foo); seq name唯一来源部分 ---------- ---------------------- ---------- ---------- ---------- 0 sqlite_自动索引_foo_2 1 u 0 1 sqlite_自动索引_foo_1 pk 0 sqlite>pragma index_xinfo(sqlite_autoindex_foo_1); seqno cid name desc coll key ---------- ---------- ---------- ---------- ---------- ---------- 0 x 0二进制1 1-10二进制0 sqlite>pragma index_xinfo(sqlite_autoindex_foo_2); seqno cid name desc coll key ---------- ---------- ---------- ---------- ---------- ---------- 0 1 y 0二进制1 1-10二进制0
sqlite> create table foo(x TEXT PRIMARY KEY, y TEXT UNIQUE);
sqlite> select * from sqlite_master;
table|foo|foo|2|CREATE TABLE foo(x TEXT PRIMARY KEY, y TEXT UNIQUE)
index|sqlite_autoindex_foo_1|foo|3|
index|sqlite_autoindex_foo_2|foo|4|
sqlite> pragma index_list(foo); seq name unique origin partial ---------- ---------------------- ---------- ---------- ---------- 0 sqlite_autoindex_foo_2 1 u 0 1 sqlite_autoindex_foo_1 1 pk 0 sqlite> pragma index_xinfo(sqlite_autoindex_foo_1); seqno cid name desc coll key ---------- ---------- ---------- ---------- ---------- ---------- 0 0 x 0 BINARY 1 1 -1 0 BINARY 0 sqlite> pragma index_xinfo(sqlite_autoindex_foo_2); seqno cid name desc coll key ---------- ---------- ---------- ---------- ---------- ---------- 0 1 y 0 BINARY 1 1 -1 0 BINARY 0