首页 > 代码库 > Oracle获取表结构信息:表名、是否视图、字段名、类型、长度、非空、主键
Oracle获取表结构信息:表名、是否视图、字段名、类型、长度、非空、主键
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 ‘U‘end 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 ‘0‘end 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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。