原 GreenPlum数据库对象类型和个数统计
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | select nsp.nspname as SchemaName ,case cls.relkind when 'r' then 'TABLE' when 'm' then 'MATERIALIZED_VIEW' when 'i' then 'INDEX' when 'S' then 'SEQUENCE' when 'v' then 'VIEW' when 'c' then 'composite type' when 't' then 'TOAST' when 'f' then 'foreign table' when 'p' then 'partitioned_table' when 'I' then 'partitioned_index' when 'p' then 'partitioned_table' when 'I' then 'partitioned_index' else cls.relkind::text end as ObjectType, COUNT(*) cnt from pg_class cls join pg_namespace nsp on nsp.oid = cls.relnamespace where nsp.nspname not in ('information_schema', 'pg_catalog','gp_toolkit') and nsp.nspname not like 'pg_toast%' GROUP BY nsp.nspname,cls.relkind UNION all SELECT n.nspname as "Schema", 'pg_proc' as "pg_proc", COUNT(*) cnt FROM pg_catalog.pg_proc p LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace WHERE pg_catalog.pg_function_is_visible(p.oid) AND n.nspname not in ('information_schema', 'pg_catalog','gp_toolkit') GROUP BY n.nspname ; |