GreenPlum批量受權(PG未測試)

建立一個自定義functionsql

create or replace function grant_all_exec(schema_name varchar,select_or_insert varchar,grantee_user varchar) returns varchar as $$
DECLARE
funcrow varchar;
BEGIN
FOR funcrow IN select 'grant '||$2||' on '||$1||'.'||tablename||' to '||$3 from  pg_tables where schemaname=$1 
LOOP
EXECUTE funcrow;
END LOOP;
return 'grant '||$2||' to '||$3||' success!';
END;
$$ language plpgsql strict ;

 select grant_all_exec('hfods','select','hfods_read')spa

"grant select to hfods_read success!"code

使用\dp hfods.t1 來查看是否受權成功blog

相關文章
相關標籤/搜索