Restore Postgres database schema from *.sql file via pgAdmin?

12,607
  • Create the new db spatial_db.
  • Select the created db and go to Menu->Plugins->PSQL Console
  • Type the command to import the db \i /path/to/file.sql

Also if it is a small file you can open it in editor and execute the sql statements.

Share:
12,607
Don
Author by

Don

Updated on June 05, 2022

Comments

  • Don
    Don almost 2 years

    I have several *.sql dump files that I would like to restore to a newly created database 'spatial_db'. I know that I can restore them via command line:

    psql -U username -h 127.0.0.1 -d spatial_db -f path/to/dump/file.sql

    Is there a way to restore the *.sql file(s) via pgAdmin as with *.backup files?

  • chrisfs
    chrisfs about 6 years
    I'm sorry, I am confused. I have PGAdmin4 , I have created a new empty database, but when I select it, I don't see an option that says Menu anywhere. If I look at the right click menu, it doesn't have an option called 'Plugins'. What am I missing here ?
  • Marlon Abeykoon
    Marlon Abeykoon over 5 years
    This answer is for PGAdminIII
  • Nathan123
    Nathan123 over 5 years
    @MarlonAbeykoon what if the file is in the .bak format. I am using pgadmin 3. Would this still work?