SELECT'-- Create Roles'; SELECT'CREATE ROLE ' || name || ' ;'AS TXT_CR FROM v_catalog.roles WHEREnameNOTIN ('public','dbadmin','pseudosuperuser','dbduser') ORDERBY1;
1 2 3 4 5
SELECT'-- Add users to roles'; SELECT'GRANT ' || all_roles || ' TO ' || user_name || ';' FROM v_catalog.users WHERE user_name NOTIN ('dbadmin') ORDERBY1;
–备份schema
1 2 3 4 5
SELECT'-- Create Schema'; SELECT'CREATE SCHEMA ' || schema_name || ';' FROM schemata WHERE schema_name NOTIN ('v_internal','v_catalog','v_monitor','TxtIndex') ORDERBY1;
–备份用户
1 2 3 4 5
SELECT'-- Create Users'; SELECT'CREATE USER ' || user_name || ' RESOURCE POOL ' || resource_pool || ' ;' FROM v_catalog.users WHERE user_name NOTIN ('dbadmin') ORDERBY1;
—各手shcema大小
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
SELECT/*+(estimated_raw_size)*/ pj.anchor_table_schema, pj.used_compressed_gb, pj.used_compressed_gb * la.ratio AS raw_estimate_gb FROM (SELECT ps.anchor_table_schema, SUM(used_bytes) / ( 1024^3 ) AS used_compressed_gb FROM v_catalog.projections p JOIN v_monitor.projection_storage ps ON ps.projection_id = p.projection_id WHERE p.is_super_projection = 't' GROUPBY ps.anchor_table_schema) pj CROSSJOIN (SELECT (SELECT database_size_bytes FROM v_catalog.license_audits ORDERBY audit_start_timestamp DESC LIMIT1) / (SELECTSUM(used_bytes) FROM V_MONITOR.projection_storage) AS ratio) la ORDERBY pj.used_compressed_gb DESC;
–备份赋权语句 –backup grants
1 2 3
select'grant '|| privileges_description || ' on '|| object_name || ' to '|| grantee||';' fromgrantswhere grantor<>grantee orderby object_name;