oracle查詢表結構語句

來源:互聯網
上載者:User

標籤:left join   col   case when   class   traints   name   log   ble   length   


select o.table_name, tmp.comments, o.COLUMN_NAME, t.comments, o.DATA_TYPE
|| CASE TRIM(o.DATA_TYPE)
WHEN ‘DATE‘ THEN
‘‘
WHEN ‘NUMBER‘ THEN
case when o.DATA_PRECISION is not null then
‘(‘ || o.DATA_PRECISION || ‘,‘ || o.DATA_SCALE || ‘)‘
else ‘‘ end
WHEN ‘CHAR‘ THEN
‘(‘ || o.DATA_LENGTH || ‘)‘
WHEN ‘VARCHAR2‘ THEN
‘(‘ || o.DATA_LENGTH || ‘)‘
END AS DATA_TYPE,
o.NULLABLE,
o.SEGMENT_COLUMN_ID,
const.COLUMN_NAME,
case when const.COLUMN_NAME is null then ‘N‘ else ‘Y‘ end as PI
from user_tab_cols o
inner join user_col_comments t on (t.table_name=o.TABLE_NAME and t.column_name=o.COLUMN_NAME)
left join (select t.table_name, c.comments
from user_tables t
left join user_tab_comments c
on t.TABLE_NAME = c.table_name) tmp
on o.TABLE_NAME = tmp.table_name
left join (select cs.table_name,cs.column_name from user_cons_columns cs,
user_constraints uc
where cs.constraint_name=uc.constraint_name
and uc.constraint_type=‘P‘
) const
on (o.COLUMN_NAME=const.column_name and o.table_name=const.table_name)
where o.table_name in (‘TEST1‘)
order by o.table_name , o.SEGMENT_COLUMN_ID

oracle查詢表結構語句

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.