Reputation: 13853
I need to restore a big table (250mb) in PostgreSQL database in console tool. How I can do this using ps_dump or psql?
Upvotes: 31
Views: 96925
Reputation: 301
psql -U postgres -d doctor_dev < /home/ravi/mydevelopment
Upvotes: 4
Reputation: 21778
psql --username yourusername --dbname yourdatabasename -f yourfile.sql
as clarified here. Depending on configuration, may ask for your password.
If it is a newly installed database engine with no your database yet, use postgres
for the database name and try to omit the username part (new installation should normally grant the full access to the current user who installed it).
If you still can’t login, edit temporarily pg_hba.conf wherever it could be in your installation and temporarily set the localhost to trusted. Then you can specify postgres both as username and as the database name.
Don’t forget to revert pg_hba.conf changes when done.
Upvotes: 27
Reputation: 6908
psql dbname < /path/to/dump.sql
You may even modify your dump on the fly if required:
sed 's/OWNER TO olduser/OWNER TO newuser/g' < /path/to/dump.sql | psql dbname
Upvotes: 19
Reputation: 23920
Just connect to database with psql
and run \i /path/to/filename.sql
.
Upvotes: 55