Q:有的时候,需要到处特定的表的特定记录,而pg_dump只能导出指定的整个表或者整个数据库,怎么办呢?

A:利用select into语句创建一个临时表,然后使用pg_dump导出临时表。

例如:

select * into test_tbl from some_tbl where some_field > some_value;

pg_dump -d db_name -t test_tbl > /tmp/test.sql

/tmp/test.sql里面包含的,就是要求的特定记录了。
Tags: ,
原来,copy命令就可以用啊,很简单,这样:

copy db_name to 'file name with path';

然后可以再把文件内容导入到数据表:

copy db_name from 'file name with path';

详细的解释见pgsql docs的sql命令一节。

还有一种办法,也许更简单:

pg_dump -d db_name -t table_name > 'file name with path'
Tags: ,
分页: 11/11 第一页 上页 6 7 8 9 10 11 最后页 [ 显示模式: 摘要 | 列表 ]