In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Case: a read-only role directly has read-only access to newly created tables under a schema without separate authorization.
First of all, you need to know that the newly created table under the default schema of PostgreSQL will not have the permission of select for an ordinary user, so I need to modify the default permission of PostgreSQl to give select to ordinary users in advance. I need to use the command alter default privileges.
Session1 (user:postgres):
# psql
Create role role1 password '123456' login
Create schema schema1
Grant usage on schema schema1 to role1
Testdb=#\ dn+ schema1
List of schemas
Name | Owner | Access privileges | Description
-+-
Schema1 | postgres | postgres=UC/postgres+ |
| | role1=U/postgres |
Alter default privileges in schema schema1 grant select on tables to role1
Testdb=#\ ddp+
Default access privileges
Owner | Schema | Type | Access privileges
-+-
Postgres | schema1 | table | role1=r/postgres
Create table schema1.t1 (C1 int,c2 varchar (10))
Insert into schema1.t1 values (1 recorder aaaa')
Testdb=#\ dp+
Access privileges
Schema | Name | Type | Access privileges | Column privileges | Policies
-+-
Schema1 | T1 | table | postgres=arwdDxt/postgres+ | |
| | role1=r/postgres | | |
Session2 read_only:
# psql-h 172.16.101.54-p 5432 testdb role1
Testdb= > select * from schema1.t1
C1 | c2
-- +-
1 | aaa
(1 row)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.