码迷,mamicode.com
首页 > 数据库 > 详细

Oracle获取表结构信息:表名、是否视图、字段名、类型、长度、非空、主键

时间:2014-07-13 00:44:11      阅读:308      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   io   div   

select
       a.TABLE_NAME as "TableName",
       case when (select count(*) from user_views v where v.VIEW_NAME =a.TABLE_NAME )>0 then V else Uend as "TableType",
       a.COLUMN_NAME as "ColumnName",
       A.COLUMN_ID as "ColumnIndex",
       a.DATA_TYPE as "DataType",
       case  
         when a.DATA_TYPE = NUMBER then
           case when a.Data_Precision is null then
             a.Data_Length
             else 
               a.Data_Precision
               end 
         else
          a.Data_Length
       end as "Length",
       case when a.nullable = N then  0 else 1 end as "IsNullable",
       b.comments as "Description", 
       case
          when (select count(*) from user_cons_columns c 
            where c.table_name=a.TABLE_NAME and c.column_name=a.COLUMN_NAME and c.constraint_name=
                (select d.constraint_name from user_constraints d where d.table_name=c.table_name and d.constraint_type   =P)
                 )>0 then 1 else 0end as "IsPK"
            
  from USER_TAB_COLS a,
       sys.user_col_comments b
 where a.table_name = b.table_name      
       and b.COLUMN_NAME = a.COLUMN_NAME       
       order by a.TABLE_NAME, a.COLUMN_ID

Oracle获取表结构信息:表名、是否视图、字段名、类型、长度、非空、主键,布布扣,bubuko.com

Oracle获取表结构信息:表名、是否视图、字段名、类型、长度、非空、主键

标签:des   style   blog   color   io   div   

原文地址:http://www.cnblogs.com/xiaotiannet/p/3838154.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!