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'));

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章