[]Oracle]查询表中每隔字段是否主键,查询表名、字段名、主键、数据类型、是否为空和注释

时间:2021-04-17 13:46:13
select
    utc.column_name as 字段名,utc.data_type 数据类型,utc.data_length 最大长度,
CASE utc.nullable WHEN 'N' THEN '否' ELSE '是' END 可空,
utc.data_default 默认值,ucc.comments 注释,UTC.table_name 表名,
CASE UTC.COLUMN_NAME 
WHEN (select
 col.column_name 
from
 user_constraints con,user_cons_columns col
where
 con.constraint_name=col.constraint_name and con.constraint_type='P'
 and col.table_name='BAS_EVENT')   THEN '是' ELSE '否' END AS 主键
from
    user_tab_columns utc,user_col_comments ucc
where
    utc.table_name = ucc.table_name
    and utc.column_name = ucc.column_name
    and utc.table_name = 'BAS_EVENT' 
order by

    column_id;

[]Oracle]查询表中每隔字段是否主键,查询表名、字段名、主键、数据类型、是否为空和注释

参考:https://www.cnblogs.com/nayitian/archive/2013/08/02/3231784.html