为什么我的新PostgreSQL数据库不为空? [英] Why is my new PostgreSQL database not empty?
问题描述
每当我从pgAdmin或使用命令行(使用CREATE DATABASE database_name )创建新数据库时,它都不为空。
Whenever I create a new database from pgAdmin or using the command line (using CREATE DATABASE database_name), it's not empty.
它
我对Psql不太熟悉,所以我不知道自己在做什么错
I'm not yet very familiar with Psql so I don't know what I'm doing wrong.
推荐答案
您可能已经在数据库 template1
中创建了对象。
You probably have created objects in the database template1
.
默认情况下,将通过克隆标准系统数据库模板1创建新数据库。可以通过写入TEMPLATE名称来指定其他模板。特别是,通过编写TEMPLATE template0,您可以创建一个仅包含您的PostgreSQL版本预定义的标准对象的原始数据库。如果您希望避免复制任何可能已添加到template1的安装本地对象,则这很有用。
因此,当您运行 create database
时, template1
数据库中的所有内容都将被复制到新数据库中。
So, anything that is in the template1
database will be copied over to the new database when you run create database
.
连接到 template1
数据库并删除所有不需要的对象。
Connect to the template1
database and drop all objects you don't want.
这篇关于为什么我的新PostgreSQL数据库不为空?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!