云数据库 GaussDB-DO:示例

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

示例

--创建用户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-opengauss/devg_03_0590.html