云数据库 GAUSSDB-DO:示例

时间:2023-11-15 14:50:51

示例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
--创建用户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-gaussdb/gaussdb_v5r2c10_0539.html