PostgreSQL創建只讀權限的用戶


1、創建只讀角色

CREATE ROLE readaccess; 

2、授予對現有表的訪問權限

GRANT USAGE ON SCHEMA public TO readaccess; GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess; 

3、授予后面新增表的訪問權限

ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess; 

4、創建用戶

CREATE USER tomek WITH PASSWORD 'mypassword'; GRANT readaccess TO testuser;


postgres數據庫查看用戶權限

1、查看某用戶的表權限

1
select  * from  information_schema.table_privileges where  grantee= 'user_name' ;
 

2、查看usage權限表

1
select  * from  information_schema.usage_privileges where  grantee= 'user_name' ;
 

3、查看存儲過程函數相關權限表

1
select  * from  information_schema.routine_privileges where  grantee= 'user_name' ;
 

4、建用戶授權

1
2
3
create  user  user_name;
alter  user  user_namewith password  '' ;
alter  user  user_namewith CONNECTION  LIMIT  20;#連接數限制
沒錢也要活的精彩


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM