开发者

Dumping psql tables with specific prefixes

开发者 https://www.devze.com 2023-02-05 18:49 出处:网络
Im currently using the tool pg_dump to dump tables from my database. I would li开发者_如何学Cke to automate this process, however, i have not found a way to specify pg_dump to dump multiple databases

Im currently using the tool pg_dump to dump tables from my database. I would li开发者_如何学Cke to automate this process, however, i have not found a way to specify pg_dump to dump multiple databases that have the same prefix.

Any help in this matter would be greatly appreciated


Examples from the manual:

To dump all tables whose names start with emp in the detroit schema, except for the table named employee_log:

$ pg_dump -t 'detroit.emp*' -T detroit.employee_log mydb > db.sql

To dump all schemas whose names start with east or west and end in gsm, excluding any schemas whose names contain the word test:

$ pg_dump -n 'east*gsm' -n 'west*gsm' -N 'test' mydb > db.sql

The same, using regular expression notation to consolidate the switches:

$ pg_dump -n '(east|west)*gsm' -N 'test' mydb > db.sql

To dump all database objects except for tables whose names begin with ts_:

$ pg_dump -T 'ts_*' mydb > db.sql


You can use parameter "-t" multiple times if you want to dump more than one table.

$ pg_dump -t table1 -t table2 mydb > dump.sql

-t table --table=table

Dump only tables (or views or sequences) matching table. Multiple

tables can be selected by writing multiple -t switches.


I'm not sure that if I undstand what you said exactly. I advise you that you can edit a shell script to dump each database .

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号