首页 > 数据库技术 > 详细

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

时间:2015-07-22 11:05:04      阅读:7011      评论:0      收藏:0      [点我收藏+]

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

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

原文:http://6666613.blog.51cto.com/6656613/1676882

(2)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!