greenplum給某個用戶賦予整個schema下所有表的權限


greenplum 雖然是postgresql的衍生產品

 

但是語法上略有不同

類似    grant all on all tables in schema schemaname to someone 就不行

報錯提示  ERROR: syntax error at or near "all"

 

所以使用了笨辦法

先生成語句

select 'grant all on table ' || schemaname || '.' || tablename || ' to usertest;' from pg_tables
where schemaname = 'panasonic_compass'

得到

"grant all on table panasonic_compass.segment_dim to usertest;"
"grant all on table panasonic_compass.wm_offline_product_weekly_fct to usertest;"
"grant all on table panasonic_compass.customer_channel_dim to usertest;"
"grant all on table panasonic_compass.wm_offline_product_daily_fct to usertest;"

把兩邊的雙引號替換掉然后統一執行就可以了。

 

同理賦予視圖權限

select 'grant all on ' || schemaname || '.' || viewname || ' to usertest;' from pg_views
where schemaname = 'panasonic_compass'

換主人

select 'alter table ' || schemaname || '.' || tablename || ' owner to usertest;' from pg_tables
where schemaname = 'panasonic_compass'

 


免責聲明!

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



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