![]() ![]() The createdb command (create a clone of the database) requires superuser privileges to execute the create database and createdb command (create a clone of the database) PostgreSQL.Ĭreate database clone_test WITH TEMPLATE db_test Below is an example of creating a database.To execute the create database and createdb command (create a clone of the database) in PostgreSQL, we need superuser privileges to execute the statement.We have created a clone of the existing database using the create database command and the pg_dump command. How to Clone a Database in PostgreSQL?īelow is the working of the clone database in PostgreSQL. Backup File Name: This is defined as the backup file name from which we have created using the pg_dump command. After creating a dump, we restored it in another database.Ĩ. Pg_dump: This is defined as creating a dump of the database by using the pg_dump command. Name of User: This is defined as the user’s name used to create a clone of the database using the existing database.ħ. We have created a new database by using the createdb command.Ħ. Createdb: This is defined as creating a new database using the createdb command. We can create a new database by using the existing database in PostgreSQL.ĥ. With Template: This is defined as creating a database using the existing template. This is an essential and useful parameter to clone the new database using the existing database.Ĥ. Old Database Name: This is defined as the old database name from which we have cloning to the new database. New Database Name: This is defined as a new database name from which we have cloning from the other database.ģ. We have created a clone of the database by using create database command in PostgreSQL.Ģ. Create Database: Create a database command is used to create a new database in PostgreSQL. Clone Database by using pg_dump Command pg_dump –U name_of_user –W user_password –d name_of_database >backup_file_name.sql (Name of backup file which database we have cloning.) psql –U name_of_user –W user_password –d (new database name) < backup_file_name.sql Parametersīelow is the parameter description syntax:ġ. Create db –O name_of_user –T old_database_name (Create new database by using old database template.) new_database_name (Name of new database which we have cloning from another database) ģ.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |