Why is my new PostgreSQL database not empty?

后端 未结 1 1070
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-12 04:36

Whenever I create a new database from pgAdmin or using the command line (using CREATE DATABASE database_name), it\'s not empty.

It contains some tables that

1条回答
  •  囚心锁ツ
    2020-12-12 05:25

    You probably have created objects in the database template1.

    Quote from the manual:

    By default, the new database will be created by cloning the standard system database template1. A different template can be specified by writing TEMPLATE name. In particular, by writing TEMPLATE template0, you can create a virgin database containing only the standard objects predefined by your version of PostgreSQL. This is useful if you wish to avoid copying any installation-local objects that might have been added to template1.

    So, anything that is in the template1 database will be copied over to the new database when you run create database.

    Connect to the template1 database and drop all objects you don't want.

    0 讨论(0)
提交回复
热议问题