我在模式中创建一个具有唯一索引的表,如下所示:
create schema s1;
create table s1.test(key int);
create unique index test_index on s1.test(key);
现在,当我查询information_schema.table_constraints
时,索引未显示。这是为什么?但是,索引正常工作:
test=# insert into s1.test(key) values (1);
INSERT 0 1
test=# insert into s1.test(key) values (1);
ERROR: duplicate key value violates unique constraint "test_index"
DETAIL: Key (key)=(1) already exists.
我在这里使用的数据库test
归当前用户所有。
更新
看起来约束也没有在public
架构中显示:
create table test(key int);
create unique index test_index on test(key);
select * from information_schema.table_constraints;
现在,当我查询information_schema.table_constraints时,不显示索引
qazxsw poi!= qazxsw poi你需要添加qazxsw poi:
UNIQUE INDEX
CONSTRAINT
- 约束+索引
CONSTRAINT
- 指数