PostgreSQL: What is the first option to create a database? First chicken?

Source: Internet
Author: User
Tags superuser permission

As follows:

The first egg?Postgres. BKI and *. SQL files under. \ share \

Initdb.exe initializes the database storage cluster according to the ipvs. BKI and *. SQL files under. \ share. The initialization cluster contains three databases and one supuser!

    • Guest calls the OS user (Postgres) of initdb.exe to connect to the database (Postgres)
    • Virgin template database tmeplate0: Template, cannot be connected
    • General template database template1: template, which can be connected
    • Guest calls the OS user (Postgres) of initdb.exe with the same name (Postgres)

 

Create Database New_db_name[Template{Template1 (default) | template_name}]

    • Template_name indicates that the template database can be any database. Super Users and owner users can do what they want. Otherwise, only the template database can allow normal users with the createdb permission to specify the database as a template.
    • Default User Database: can be completely killed! By default, PostgreSQL allows the template1 default database to accept user connections!
    • The default database can be rebuilt, which is a normal user database.
    • Template1 template database can also be killed! But you need to know that it is basically the last database to be deleted! If there are no other normal user databases, you should re-prepare initdb.exe !!!
    • The template1 database can be rebuilt! Other templates are required! If the database does not exist, you cannot use the create database without the template clause.

 

Two attribute flags of the database

    • Datistemplate: whether it is a template database that can be used by common users. It is invalid for supuser and owner users.
    • Datallowconn: whether to allow users to connect to the database! Any database to be cloned as a template must be clean and cannot be connected! This is also true for supuser and owner users!

 

Create DatabaseDb_name

[

[With]

[Owner [=]Other_role_name] -- only superuser can specify other owners. Default current role

[Encoding [=]Encoding_name] -- character set encoding, default utf8

[Template [=]Template_db_name] -- (Template) database, default template1

[Tablespace [=]Tablespace_name] -- default tablespace, default pg_default

[Connection limit [=]Connlimit] -- the number of running connections is not limited by default (-1)

]

You must have the create database permission or superuser permission to create a database.

Cannot be executed in a transaction

UseProgramCreatedb.exe encapsulates the create database statement.

 

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.