pg中,獲得一個表的表結構,字段名,註釋等

獲得一個表中的結構,這個在數據庫操做中這個很是有用,經常用於一些數據庫中的自動化腳本,sql

SELECT col_description(a.attrelid,a.attnum) as comment,
        format_type(a.atttypid,a.atttypmod) as type,
                                  a.attname as name,
                               a.attnotnull as notnull  
      FROM pg_class as c,
       pg_attribute as a  
   where c.relname = 'kemdata.memory_usage'
     and a.attrelid = c.oid
     and a.attnum>0 ;
相關文章
相關標籤/搜索