Oracle Database 导出当前用户数据字典

一个简单的 sql 语句, 导出当前登录用户的数据字典.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
SELECT t1.TABLE_NAME AS "表名",
t3.COMMENTS AS "表备注",
t1.COLUMN_NAME AS "字段名",
DECODE(
t1.CHAR_LENGTH,
0,
DECODE(
t1.DATA_SCALE,
NULL,
t1.DATA_TYPE,
t1.DATA_TYPE || '(' || t1.DATA_PRECISION || ',' || t1.DATA_SCALE || ')'
),
t1.DATA_TYPE || '(' || t1.CHAR_LENGTH || ')'
) AS "字段类型",
t1.DATA_DEFAULT AS "默认值",
t1.NULLABLE AS "能否为空",
t2.COMMENTS AS "字段备注"
FROM sys.user_tab_columns t1,
sys.user_col_COMMENTS t2,
user_tab_COMMENTS t3
WHERE t1.TABLE_NAME = t2.TABLE_NAME
AND t1.COLUMN_NAME = t2.COLUMN_NAME
AND t1.TABLE_NAME = t3.TABLE_NAME