PostgreSQL dump/restore

£可爱£侵袭症+ 提交于 2020-01-04 02:46:09

问题


I don't want to Dump the entire table but only certain records in a table in my dump file and later restore the same.
P.S.: I want to do the same for more than 1 table in my database but dump it in a single file.
Is this possible? If yes then how do i go about it?

Thank in advance.


回答1:


The COPY command?




回答2:


Should be possible using Jailer.




回答3:


create temp_tables from sqlquery

sqlquery can be formed as projection like 'select columns from table'

then use pg_dump to dump all temporary tables using --table option. pgadmin can help dumping tables in a single file here.

Restore all temp tables from pgadmin and run INSERT query on main table.




回答4:


As @Pondlife mentioned in his answer had to use COPY command but did not solve my Problem of getting all the dump data into a single file.
So from the idea given by Craig Ringer made individual files for each table and got all the files compressed into a single archive file.
For restore uncompressed the archive to generate individual files later used them to restore the Tables.

Had to answer my own question so it might help somebody.



来源:https://stackoverflow.com/questions/8489464/postgresql-dump-restore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!