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