Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export and import table dump (.sql) using pgAdmin

I have pgAdmin version 1.16.1

So, for exporting table dumm I do:

Right click on table, then in menu click on backup, then in Format choice Plain and save file as some_name.sql

Then I remove table.

Ok, now I need import table backup some_name.sql into database.

How to do this? I can't find how to import table's .sql dump into database using pgAdmin.

Can you help me please?

like image 801
Oto Shavadze Avatar asked Sep 11 '13 08:09

Oto Shavadze


People also ask

How do I export a .SQL file to a PostgreSQL database?

In the left pane of the phpPgAdmin window, expand Servers, expand PostgreSQL, and then click the name of the database that you want to export. On the top menu bar, click Export. Under Format, click Structure and data. Under Options, in the Format list box, select SQL.

Can we import .SQL file in PostgreSQL?

To import SQL script file into PostgreSQL database using this tool, take the following steps: Select the database. Navigate to the "SQL" button. Click the "Choose File" (or "Browse") button and select the SQL file from your computer.


2 Answers

  1. In pgAdmin, select the required target schema in object tree (databases ->your_db_name -> schemas -> your_target_schema)
  2. Click on Plugins/PSQL Console (in top-bar)
  3. Write \i /path/to/yourfile.sql
  4. Press enter
like image 115
Tomas Greif Avatar answered Sep 20 '22 12:09

Tomas Greif


An another way, you can do it easily with CMD on Windows

Put your installed version (mine is 11).

cd C:\Program Files\PostgreSQL\11\bin\ 

and run simple query

psql -U <postgre_username> -d <db_name> < <C:\path\data_dump.sql> 

enter password then wait the final console message.

Note: Make sure to remove <> from the above query except for the < between db_name & file path.

Example: psql -U postgres -d dumb_db < D:\db_dump.sql

like image 30
EgoistDeveloper Avatar answered Sep 22 '22 12:09

EgoistDeveloper