云数据库 GAUSSDB-DO:示例

时间:2024-11-02 18:53:04

示例

--创建用户webuser。
openGauss=# CREATE USER webuser PASSWORD 'xxxxxxxxx';

--授予用户webuser对模式tpcds下视图的所有操作权限。
openGauss=# DO $$DECLARE r record;
BEGIN
    FOR r IN SELECT c.relname table_name,n.nspname table_schema 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/centralized-devg-v2-gaussdb/devg_03_0592.html