300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > oracle怎么通过sql查看表的结构 – 数据库 – 前端

oracle怎么通过sql查看表的结构 – 数据库 – 前端

时间:2020-06-18 11:14:49

相关推荐

oracle怎么通过sql查看表的结构 – 数据库 – 前端

利用sql语句查询某个表的结构的方法:

通过Oracle中的user_tab_cols, user_col_comments, user_constraints, user_cons_columns表联合查询。 1、user_tab_cols用来获取对应用户表的列信息; 2、user_col_comments用来获取对应用户表列的注释信息; 3、user_constraints用来获取用户表的约束条件; 4、user_cons_columns约束中用户可访问列。

示例代码:

select t.table_name, t.column_name, t.data_type, t.data_length, t.nullable, t.column_id, ments, (SELECT CASE WHEN t.column_name = m.column_name THEN 1 ELSE 0ENDFROM DUAL) iskey FROM user_tab_cols t, user_col_comments c, (select m.column_namefrom user_constraints s, user_cons_columns m where lower(m.table_name) = ‘qh_outstoresabinfo’ and m.table_name = s.table_name and m.constraint_name = s.constraint_name and s.constraint_type = ‘P’) m WHERE lower(t.table_name) = ‘qh_outstoresabinfo’ and c.table_name = t.table_name and c.column_name = t.column_name and t.hidden_column = ‘NO’ order by t.column_id

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。