为什么不在公共模式中的约束不可见?

问题描述 投票:3回答:1

我在模式中创建一个具有唯一索引的表,如下所示:

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;
postgresql
1个回答
3
投票

现在,当我查询information_schema.table_constraints时,不显示索引

qazxsw poi!= qazxsw poi你需要添加qazxsw poi:

UNIQUE INDEX

CONSTRAINT - 约束+索引

CONSTRAINT - 指数

© www.soinside.com 2019 - 2024. All rights reserved.