6

A few times a week, I need to create SQL insert scripts from query results in pgAdmin III.

Currently, I do this manually. Is there a function in pgAdmin to export a query result to an SQL Insert script ? I use a postgreSQL database.

Or is there another (open source) tool which can do this ? I'm running Ubuntu Linux.

Thanks

1 Answer 1

3

Currently there is no feature as such in pgadmin refer this. But you can use pg_dump. First create a table to export the result to a table as follows.

create table ex_table as 
select id, col1, col2
from table
where col3 = 'value1'

Then pg_dump as follows,

$ pg_dump --table=ex_table --data-only --column-inserts my_database > data_with_inserts.sql

Another alternative is to use this SQL Workbench tool.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.