每周有几次,我需要根据 pgAdmin III 中的查询结果创建 SQL 插入脚本。
目前,我手动执行此操作。 pgAdmin 中是否有将查询结果导出到 SQL Insert 脚本的函数?我使用 postgreSQL 数据库。
或者是否有其他(开源)工具可以做到这一点?我正在运行 Ubuntu Linux。
谢谢
最佳答案
目前 pgadmin 中没有这样的功能,请引用 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 工具。
关于postgresql - 从查询结果创建插入脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38426643/