简体   繁体   English

通过pgAdmin从* .sql文件恢复Postgres数据库架构?

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

I have several *.sql dump files that I would like to restore to a newly created database 'spatial_db'. 我有几个* .sql转储文件,我想还原到新创建的数据库'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? 有没有办法像* .backup文件一样通过pgAdmin恢复* .sql文件?

  • Create the new db spatial_db . 创建新的spatial_db
  • Select the created db and go to Menu->Plugins->PSQL Console 选择创建的数据库,然后转到Menu->Plugins->PSQL Console
  • Type the command to import the db \\i /path/to/file.sql 键入命令以导入db \\i /path/to/file.sql

Also if it is a small file you can open it in editor and execute the sql statements. 另外,如果它是一个小文件,则可以在编辑器中将其打开并执行sql语句。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM