PostgreSQL authorizes the user for existing future tables and views

Source: Internet
Author: User
Tags postgresql
Due to development requirements:
(1) Create a readonly user on multiple PostgreSQL instacne, only have SELECT permission on the table or view (including materialized view) in the database, and have SELECT permission for the newly created table and view. We know PostgreSQL.
New table under schema, for an already existing user does not automatically give the SELECT permission, we need to use the grant SELECT ... Manual to execute, so it is troublesome, always can not create a new table every time, we have to empower once, to know that we have a lot of examples, always can not put time on such meaningless things, and we can not always monitor what PostgreSQL has a new table, so we need to pre-authorize the future table, Viewed the PostgreSQL website and found the command alter default privileges ... This function can be implemented.


(2) Alter default privileges does not have the ability to authorize existing tables and views, so you want to empower both present and future objects, and you will need to use the grant Select to assign the available tables.


(3) because there are so many Db/schenma to execute, a single command is less realistic and requires scripting and batch execution.



You can refer to the test procedure for how to implement:

http://blog.51cto.com/darrenmemos/2086198


The script reads as follows:


PostgreSQL authorizes the user for existing future tables and views

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.