user514310
user514310

Reputation:

psql not restoring the database dump

I am trying to restore the database. but database not restoring the sql dump. I am running following command. My sql dump have tables and copy statements.

psql -X -h localhost -d <database> -f dump.sql

I also tried in psql interactively

Edit: Removed the ; suggested by a_horse_with_no_name.

\connect mydatabase
\i dump.sql

it runs with no errors. But its not creating any database tables. Any idea? Thanks

Edit 2: There is no any error in log files.

Upvotes: 3

Views: 3657

Answers (2)

Nadine
Nadine

Reputation: 1638

Since it ran with no errors, it's very possible that the dump was imported, but the tables aren't in the public schema, so you aren't seeing them when you enter \dt. Check if the tables are there using these commands:

\dt .*.

Or write a select statement like the one below explicitly mentioning the database name:

SELECT * FROM <database_name>.<table_name>;

Otherwise, the only tables that are displayed are those that are in the public schema

Upvotes: 1

dotcomly
dotcomly

Reputation: 2214

Try passing the file in. The drop and create statements are optional, just to be sure

dropdb <database>
createdb <database>
psql <database> < dump.sql

Upvotes: 0

Related Questions