Export specific rows from a PostgreSQL table as INSERT SQL script

后端 未结 9 745
野趣味
野趣味 2020-11-30 17:01

I have a database schema named: nyummy and a table named cimory:

create table nyummy.cimory (
  id numeric(10,0) not null,
  name c         


        
9条回答
  •  旧巷少年郎
    2020-11-30 17:10

    This is an easy and fast way to export a table to a script with pgAdmin manually without extra installations:

    1. Right click on target table and select "Backup".
    2. Select a file path to store the backup. As Format choose "Plain".
    3. Open the tab "Dump Options #2" at the bottom and check "Use Column Inserts".
    4. Click the Backup-button.
    5. If you open the resulting file with a text reader (e.g. notepad++) you get a script to create the whole table. From there you can simply copy the generated INSERT-Statements.

    This method also works with the technique of making an export_table as demonstrated in @Clodoaldo Neto's answer.

提交回复
热议问题