Обсуждение: pg dump only indexes

Поиск
Список
Период
Сортировка

pg dump only indexes

От
"Campbell, Lance"
Дата:

PostgreSQL 9.2

Is there a way to use pg_dump to dump just indexes on a database?

 

 

Thanks,

 

Lance Campbell

Software Architect

Web Services at Public Affairs

217-333-0382

University of Illinois at Urbana-Champaign logo

 

 

Вложения

Re: pg dump only indexes

От
Vibhor Kumar
Дата:
On Dec 16, 2013, at 5:42 PM, Campbell, Lance <lance@illinois.edu> wrote:

> PostgreSQL 9.2
> Is there a way to use pg_dump to dump just indexes on a database?

You can use --section=post-data and grep the INDEXES.

Or you can use pg_catalog.pg_indexes.indexdef for indexes.
http://www.postgresql.org/docs/9.2/static/view-pg-indexes.html

Thanks & Regards,
Vibhor Kumar
Blogs:http://vibhork.blogspot.com
http://vibhorkumar.wordpress.com



Re: pg dump only indexes

От
bricklen
Дата:
On Mon, Dec 16, 2013 at 2:42 PM, Campbell, Lance <lance@illinois.edu> wrote:

PostgreSQL 9.2

Is there a way to use pg_dump to dump just indexes on a database?

 


I don't think you can do that using pg_dump in 9.2, but you could probably replicate the functionality using a COPY statement.
Eg
COPY (select indexdef||';' as idxdef from pg_indexes where schemaname <> 'pg_catalog' order by 1) TO '/path/to/your/file.sql';