Postgres user's permissions to create a database __ database

Source: Internet
Author: User
user permissions to create a database

(1) Check to confirm that Superuser Highgo has the right to create a database, and that normal user A does not have permission to create a database

Highgo=#\du

List of roles

Role name | Attributes | Member of

-----------+------------------------------------------------+-----------

A | | {}

Highgo | Superuser, create role, create DB, Replication | {}

highgo= #select Current_User;

Current_User

--------------

Highgo

(1row)

highgo= #create database highgo_t;

CreateDatabase

Highgo=#\c Highgo A

Youare now connected to database "Highgo" as User "a".

Highgo=>create database a_t;

Error: Insufficient permissions to create database

Highgo=>

(2) Giving ordinary User a permission to create a database, but not giving superuser privileges, user A can create a database

highgo= #alter User A createdb;

Alterrole

Highgo=#\du

List of roles

Role name | Attributes | Member of

-----------+------------------------------------------------+-----------

A | Create DB | {}

Highgo | Superuser, create role, create DB, Replication | {}

Highgo=#\c Highgo A

Youare now connected to database "Highgo" as User "a".

Highgo=>create database a_t;

CreateDatabase

Highgo=>\l

List of databases

Name | Owner |  Encoding |   Collate | Ctype | Access Privileges

-----------+--------+----------+------------+------------+-------------------

a_t | A | UTF8 | Zh_cn.utf8 | Zh_cn.utf8 |

Highgo | Highgo | UTF8 | Zh_cn.utf8 |zh_cn.utf8 | =tc/highgo +

|          |            |            | | Highgo=ctc/highgo

highgo_t | Highgo | UTF8 | Zh_cn.utf8 |zh_cn.utf8 |

Template0 | Highgo | UTF8 | Zh_cn.utf8 | Zh_cn.utf8 | =c/highgo +

|          |            |            | | Highgo=ctc/highgo

template1 | Highgo | UTF8 | Zh_cn.utf8 | Zh_cn.utf8 | =c/highgo +

|          |            |            | | Highgo=ctc/highgo

(5rows)

(3) gives User a superuser the right to create a database, but does not give it a separate permission, at which point User A can create a database

highgo= #alter User A nocreatedb;

Alterrole

Highgo=#\du

List of roles

Role name | Attributes | Member of

-----------+------------------------------------------------+-----------

A | | {}

Highgo | Superuser, create role, create DB, Replication | {}

highgo= #alter User A superuser;

Alterrole

Highgo=#\du

List of roles

Role name | Attributes | Member of

-----------+------------------------------------------------+-----------

A | Superuser | {}

Highgo | Superuser, create role, create DB, Replication | {}

Highgo=#\c Highgo A

Youare now connected to database "Highgo" as User "a".

highgo= #create database a_tb;

CreateDatabase

Highgo=#\l

List of databases

Name | Owner |  Encoding |   Collate | Ctype | Access Privileges

-----------+--------+----------+------------+------------+-------------------

a_t | A | UTF8 | Zh_cn.utf8 | Zh_cn.utf8 |

A_TB | A | UTF8 | Zh_cn.utf8 | Zh_cn.utf8 |

Highgo | Highgo | UTF8 | Zh_cn.utf8 |zh_cn.utf8 | =tc/highgo +

|          |            |            | | Highgo=ctc/highgo

highgo_t | Highgo | UTF8 | Zh_cn.utf8 | Zh_cn.utf8 |

Template0 | Highgo | UTF8 | Zh_cn.utf8 | Zh_cn.utf8 | =c/highgo +

|          |            |            | | Highgo=ctc/highgo

template1 | Highgo | UTF8 | Zh_cn.utf8 | Zh_cn.utf8 | =c/highgo +

|          |            |            | | Highgo=ctc/highgo

(6rows)

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.