简体   繁体   中英

How do you create a database from a backup with PostgreSQL?

In SQL Server, I can create a new database on the server from a backup from another box. I can't seem to find that functionality in pgAdmin4 with PostgreSQL10. It seems like all I can do is restore an existing database. Do I need to just create a blank database first?

You can use --create or -C in pg_dump function to make database. From Documentation :

Begin the output with a command to create the database itself and reconnect to the created database. (With a script of this form, it doesn't matter which database in the destination installation you connect to before running the script.)

For syntax :

pg_dump -C -U your_user -d your_db > filename.sql

or

pg_dump --create -U your_user -d your_db > filename.sql

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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