greenplum給某個用戶賦予整個schema下全部表的權限

greenplum 雖然是postgresql的衍生產品sql

 

可是語法上略有不一樣post

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

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

 

因此使用了笨辦法code

先生成語句blog

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;"

把兩邊的雙引號替換掉而後統一執行就能夠了。table

 

同理賦予視圖權限class

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

換主人test

select 'alter table ' || schemaname || '.' || tablename || ' owner to usertest;' from pg_tables
where schemaname = 'panasonic_compass'
相關文章
相關標籤/搜索