oracle查询数据字典的sql

使用的sql语句如下:

select 
t1.username 用户,
t2.TABLE_NAME 表名称,
t3.comments 表业务含义,
t2.COLUMN_NAME 字段名称,
t4.comments 字段业务含义,
t2.DATA_TYPE 字段类型,
t2.DATA_LENGTH 字段长度
from dba_users t1,
dba_tab_columns t2,
dba_tab_comments t3,
dba_col_comments t4
where t1.username not in('SYS','SYSTEM','ACCESS_LOG') and t1.account_status='OPEN'
and t2.OWNER=t1.username
and t3.table_name=t2.TABLE_NAME and t3.owner=t2.OWNER
and t4.table_name=t2.TABLE_NAME and t4.owner=t2.owner and t4.column_name=t2.COLUMN_NAME
order by t1.username,t2.TABLE_NAME,t2.COLUMN_ID

其实还应该关联dba_tables表,但是关联这个表会造成执行时间加长,dba_tab_columns中已经提供了表名信息,不过以上的语句会造成查出的结果中有一些临时表。

猜你喜欢

转载自www.cnblogs.com/vanwoos/p/9242186.html