1. 程式人生 > 其它 >Oracle資料庫中檢視所有表和欄位以及表註釋.欄位註釋

Oracle資料庫中檢視所有表和欄位以及表註釋.欄位註釋

1、獲取表:

select table_name from user_tables; //當前使用者擁有的表

select table_name from all_tables; //所有使用者的表

select table_name from dba_tables; //包括系統表

select table_name from dba_tables where owner='使用者名稱'

ALL_OBJECTS describes all objects accessible to the current user. 描述當前使用者有訪問許可權的所有物件
DBA_OBJECTS describes all objects in the database. 描述了資料庫中的所有物件
USER_OBJECTS describes all objects owned by the current user. 描述了當前使用者所擁有的所有物件
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
**user_tables:**TABLE_NAME,TABLESPACE_NAME,LAST_ANALYZED等

**dba_tables:**ower,table_name,tablespace_name,last_analyzed等

**all_tables:**ower,table_name,tablespace_name,last_analyzed等

**all_objects:**ower,object_name,subobject_name,object_id,created,last_ddl_time,timestamp,status等

2、獲取表字段:

select * from user_tab_columns where Table_Name=‘使用者表’;

select * from all_tab_columns where Table_Name=‘使用者表’;

select * from dba_tab_columns where Table_Name=‘使用者表’;

3、獲取表註釋:

user_tab_comments;表註釋

select * from user_tab_comments

user_tab_comments:table_name,table_type,comments

相應的還有dba_tab_comments,all_tab_comments,這兩個比user_tab_comments多了ower列。
1.
2.
3.
4.
5.
6.
7.
4、獲取欄位註釋:

select * from user_col_comments

user_col_comments:table_name,column_name,comments

相應的還有dba_col_comments,all_col_comments,這兩個比user_col_comments多了ower列。


user_col_comments;表字段註釋(列註釋)
USER_COL_COMMENTS 檢視顯示已經為表中的列輸入的註釋。這些註釋通過comment命令新增到資料庫中。USER_COL_COMMENTS 檢視包含3 列:

Table_Name 表名或檢視名

Column_Name 列名

Comments 已經為該列輸入的註釋

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
5、查表字段註釋事例:

登入後複製
檢視JH表中欄位的註釋:
select table_name,column_name,comments from user_col_comments where table_name='JH';
TABLE_NAME COLUMN_NAME COMMENTS
-------------------------- --------------------------- -----------------------
JH CONTACT_NAME 聯絡人姓名
1.
2.
3.
4.
5.

-----------------------------------
©著作權歸作者所有:來自51CTO部落格作者M_ling的原創作品,如需轉載,請註明出處,否則將追究法律責任
Oracle資料庫中檢視所有表和欄位以及表註釋.欄位註釋
https://blog.51cto.com/meiling/2068902