云数据库 GaussDB-DO:示例

时间:2023-11-01 16:22:51

示例

 1 2 3 4 5 6 7 8 910111213141516
--创建用户webuser。openGauss=# CREATE USER webuser PASSWORD 'xxxxxxxxxx';--授予用户webuser对模式tpcds下视图的所有操作权限。openGauss=# DO $$DECLARE r record;BEGIN    FOR r IN SELECT c.relname,n.nspname FROM pg_class c,pg_namespace n              WHERE c.relnamespace = n.oid AND n.nspname = 'tpcds' AND relkind IN ('r','v')    LOOP        EXECUTE 'GRANT ALL ON ' || quote_ident(r.table_schema) || '.' || quote_ident(r.table_name) || ' TO webuser';    END LOOP;END$$;--删除用户webuser。openGauss=# DROP USER webuser CASCADE;
support.huaweicloud.com/distributed-devg-v2-opengauss/gaussdb-v5r2c10-0610.html