ORACLE quickly obtains the data dictionary of certain tables

When I was doing data marts in the past, I often collected the data dictionaries of the mart only after the work was done. It was still very troublesome to find them one by one every time. So I wrote a piece of sql to run it out, which is more convenient. The following applies to ORACLE.

SELECT t1.table_name 表英文名
,t3.COMMENTS 表中文名
,t1.column_id  字段序号 
,t1.column_name 字段英文名
,t2.comments  字段中文名
,t1.data_type 字段类型
,CASE WHEN T4.COLUMN_NAME IS NOT NULL THEN 'Y' ELSE 'N' END 主键
,t1.nullable  是否允许空值
from all_tab_columns t1
LEFT JOIN all_col_comments t2
ON t2.table_name = t1.table_name
AND t2.column_name = t1.column_name
LEFT JOIN all_tab_comments t3
ON t3.TABLE_NAME = t1.TABLE_NAME
LEFT JOIN  All_Cons_Columns T4
ON T4.TABLE_NAME = T1.TABLE_NAME
AND T4.COLUMN_NAME = T1.COLUMN_NAME
WHERE t1.table_name IN( 'TABLE_NAME1' ,'TABLE_NAME2'
)
ORDER BY T1.TABLE_NAME, t1.column_id
;

Supongo que te gusta

Origin blog.csdn.net/limuqing_134/article/details/106373575
Recomendado
Clasificación