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'