oracle通過sql獲取表結構
阿新 • • 發佈:2019-01-10
-- 獲取T_POL_CUSTOMER_NEW表的欄位名、欄位型別、預設值、是否允許為空、欄位說明
select t1.column_name,data_type,data_default,nullable,comments from (
select table_name,column_name,data_type,data_default,nullable from user_tab_cols where Table_Name='T_POL_CUSTOMER_NEW'
)t1
RIGHT JOIN
(
select column_name,comments from user_col_comments where Table_Name='T_POL_CUSTOMER_NEW'
)t2
on t1.column_name=t2.column_name;
獲取結果:
注:如果需要獲取欄位的其他屬性,可以先查詢 user_tab_cols 和 user_col_comments 中有什麼再去進行篩選。
eg:
select * from user_tab_cols where Table_Name='T_POL_CUSTOMER_NEW';
select * from user_col_comments where Table_Name='T_POL_CUSTOMER_NEW';