Oracle查询表结构的一些相关语句
生活随笔
收集整理的這篇文章主要介紹了
Oracle查询表结构的一些相关语句
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
2019獨角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
?
select * from all_tab_comments; --查詢所有用戶的表、視圖等select * from user_tab_comments; --查詢當(dāng)前用戶的所有表、視圖等select * from all_col_comments; --查詢所有用戶的表的列名和注釋select * from user_col_comments; --查詢當(dāng)前用戶的表的列名和注釋select * from all_tab_columns; --查詢所有用戶的表的列的結(jié)構(gòu)信息(沒有備注)select * from user_tab_columns; --查詢當(dāng)前戶的表的列的結(jié)構(gòu)信息(沒有備注)?
--查詢某張表的相信信息(包括列名、數(shù)據(jù)類型、長度、是否為空、是否主鍵、是否外鍵、備注) SELECT USER_TAB_COLS.COLUMN_NAME as 列名 , USER_TAB_COLS.DATA_TYPE as 數(shù)據(jù)類型, USER_TAB_COLS.DATA_LENGTH as 長度, USER_TAB_COLS.NULLABLE as 是否為空, case 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 = '表名' and col.column_name = USER_TAB_COLS.COLUMN_NAME) = USER_TAB_COLS.COLUMN_NAME THEN 'Y' ELSE 'N' ENDas 是否主鍵, case when (select count(*) from user_constraints con, user_cons_columns col, (select t2.table_name,t2.column_name,t1.r_constraint_name from user_constraints t1,user_cons_columns t2 where t1.r_constraint_name=t2.constraint_name and t1.table_name='表名') r where con.constraint_name=col.constraint_name and con.r_constraint_name=r.r_constraint_name and con.table_name='表名' and col.column_name = USER_TAB_COLS.COLUMN_NAME) > 0 then 'Y' else 'N' END as 是否外鍵 , user_col_comments.comments as 備注 FROM USER_TAB_COLS inner join user_col_comments on user_col_comments.TABLE_NAME = USER_TAB_COLS.TABLE_NAME and user_col_comments.COLUMN_NAME=USER_TAB_COLS.COLUMN_NAME and USER_TAB_COLS.TABLE_NAME = '表名' ORDER BY USER_TAB_COLS.COLUMN_ID;
轉(zhuǎn)載于:https://my.oschina.net/lovedreamland/blog/34530
總結(jié)
以上是生活随笔為你收集整理的Oracle查询表结构的一些相关语句的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: putty中文乱码
- 下一篇: sql2005还原出现“受限制用户”解决