如何查看表的所有现有索引?例如给定表mytable,如何用适当的列查看他的每个索引?
2 回答
2
试试这个 SQL
SELECT * FROM pg_indexes WHERE tablename = 'mytable';
于 2013-05-10T09:43:14.993 回答
1
在psql使用\d命令:
postgres=> create table foo (id integer not null primary key, some_data varchar(20));
创建表
postgres=> 在 foo (some_data) 上创建索引 foo_data_idx;
创建索引
postgres=> \d+ foo
表“public.foo”
专栏 | 类型 | 修饰符 | 存储 | 统计目标 | 描述
-----------+-----------+------------+-- --------+--------------+------------
编号 | 整数 | 不为空 | 平原 | |
一些数据 | 字符变化(20) | | 扩展 | |
索引:
"foo_pkey" 主键,btree (id)
“foo_data_idx” btree (some_data)
有 OID:没有
postgres=>
其他 SQL 工具有其他方法来显示此信息。
于 2013-05-10T09:46:32.580 回答