Thursday , November 14 2024

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.

Loading

About Faruk Erdem

Leave a Reply

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