每周有几次,我需要在pgAdmin III中根据查询结果创建SQL insert脚本。
目前,我手动执行此操作。pgAdmin中是否有一个函数可以将查询结果导出到SQL Insert脚本?我使用postgreSQL数据库。
或者有没有其他(开源)工具可以做到这一点?我运行的是Ubuntu Linux。
谢谢
发布于 2016-07-31 23:19:40
目前在pgadmin refer this中还没有这样的功能。但是你可以使用pg_dump。首先创建一个表,将结果导出到一个表中,如下所示。
create table ex_table as select id, col1, col2 from table where col3 = 'value1'
然后pg_dump如下所示:
$ pg_dump --table=ex_table --data-only --column-inserts my_database > data_with_inserts.sql
另一种选择是使用this SQL Workbench工具。
https://stackoverflow.com/questions/38426643
相似问题