1
如何查看錶格的所有已存在的索引?例如給出表mytable
,如何查看他的每個索引與適當的列?查看錶格的所有索引和適當的列
如何查看錶格的所有已存在的索引?例如給出表mytable
,如何查看他的每個索引與適當的列?查看錶格的所有索引和適當的列
試試這個SQL
SELECT * FROM pg_indexes WHERE tablename = 'mytable';
在psql
使用\d
命令:
postgres=> create table foo (id integer not null primary key, some_data varchar(20)); CREATE TABLE postgres=> create index foo_data_idx on foo (some_data); CREATE INDEX postgres=> \d+ foo Table "public.foo" Column | Type | Modifiers | Storage | Stats target | Description -----------+-----------------------+-----------+----------+--------------+------------ id | integer | not null | plain | | some_data | character varying(20) | | extended | | Indexes: "foo_pkey" PRIMARY KEY, btree (id) "foo_data_idx" btree (some_data) Has OIDs: no postgres=>
其他SQL工具必須顯示該信息的其他方式。
對不起,已更新! – Raptor 2013-05-10 09:44:42