2016-09-15 2 views
1
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_master은 해당 열이 어떤 열인지 알려줍니다. 그러나 알 수 있듯이 (암묵적이지 않은) PRIMARY KEYUNIQUE에 의해 암시 적으로 생성 된 인덱스의 경우이 정보는 없습니다. 어느 날 autoindex이 어떤 것인지 알 수있는 확실한 방법이 있습니까?SQLite 내부 색인이 어떤 열인지 알 수있는 방법이 있습니까?

답변

1

내부 색인과 명시 적으로 작성된 색인은 차이가 없습니다.

 
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 
: 당신은 같은 프라 그마 ( index_list, index_info, index_xinfo)와 그들에 대한 정보를 얻을 수 있습니다
관련 문제