Monday , January 30 2023

PSQL Create Database With Template

When creating new projects and new databases, we can use the template0 database instead of writing one by one.

Example:

We can create it using the command

If you want to do this through pgadmin, you can select the database in the template tab in the definition section.

You can use TEMPLATE to create a copy of a different database, but to do this, there must be no session on the database you want to copy.

Example:

In the example above we are creating a copy of the customers table in the format customers_new.

Faruk Erdem
Author: Faruk Erdem

About Faruk Erdem

Leave a Reply

Your email address will not be published. Required fields are marked *