Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How restore a PostgreSQL table from *.sql using pg_dump or psql?

Tags:

I need to restore a big table (250mb) in PostgreSQL database in console tool. How I can do this using ps_dump or psql?

like image 398
NiLL Avatar asked Feb 24 '12 09:02

NiLL


People also ask

How do I restore a PostgreSQL database from SQL?

To restore a PostgreSQL database, you can use the psql or pg_restore utilities. psql is used to restore text files created by pg_dump whereas pg_restore is used to restore a PostgreSQL database from an archive created by pg_dump in one of the non-plain-text formats (custom, tar, or directory).

What is pg_dump in PostgreSQL?

pg_dump is a utility for backing up a PostgreSQL database. It makes consistent backups even if the database is being used concurrently. pg_dump does not block other users accessing the database (readers or writers). pg_dump only dumps a single database.


1 Answers

Just connect to database with psql and run \i /path/to/filename.sql.

like image 60
Tometzky Avatar answered Sep 22 '22 15:09

Tometzky