GP数据库笔记―表结构查询,表占用空间查询

GP数据库中表结构查询的方法:

select d.nspname

      ,obj_description(d.oid)

      ,c.relname

      ,obj_description(c.oid)

      ,a.attnum

      ,a.attname

      ,e.data_type

      ,col_description(c.oid,a.attum)

      ,e.is_nullable

      ,case where e.data_type ~  'character'

                  then e.character_maximum_length|| ''

            where e.data_type ~  'numeric'

                  then ((('('||e.numeric_precision)||',')||e.numeric_scale)||')'

            else ''

       end

 from pg_class

 left join pg_acctribute a

   on a.atttypid = t.oid

 join pg_namespace d

    on d.oid = c.relnamespace

   and d.nspname not like 'pg_%'

  join information_schema.cloumns e

    on c.relname = e.table_name::name

   and a.attnum = e.ordinal_position

   and e.table_schema::name = d.nspname

 where c.relname !~ 'pg|prt'

   and a.attnum > 0

 order by d.nspname

         ,c.relname

         ,a.attnum

;


GP数据库占用表空间

select pg_size_pretty(pg_relation_size('schema_name.table_name'));

select pg_size_pretty(pg_database_size('db_name'));

你可能感兴趣的:(数据库,character,where,空间)