oracle comment命令用法示例分享
oracle中用comment on命令給表或字段加以說明,語法如下:
COMMENT ON
{ TABLE [ schema. ]
{ table | view }
| COLUMN [ schema. ]
{ table. | view. | materialized_view. } column
| OPERATOR [ schema. ] operator
| INDEXTYPE [ schema. ] indextype
| MATERIALIZED VIEW materialized_view
}
IS 'text' ;
用法如下:
1.對表的說明
comment on table table_name is 'comments_on_tab_information';
2.對表中列的說明
comment on column table.column_name is 'comments_on_col_information';
3.查看表的說明
SQL> select * from user_tab_comments where TABLE_NAME='EMPLOYEES';
TABLE_NAME TABLE_TYPE COMMENTS
------------------------------ ----------- ----------
EMPLOYEES TABLE 員工表
SQL> select * from user_tab_comments where comments is not null;
TABLE_NAME TABLE_TYPE COMMENTS
------------------------------ ----------- --------------------------
EMPLOYEES TABLE 員工表
4.查看表中列的說明
SQL> select * from user_col_comments where TABLE_NAME='EMPLOYEES';
TABLE_NAME COLUMN_NAME COMMENTS
------------------------------ ------------------------------ ------------
EMPLOYEES EMPLOYEE_ID
EMPLOYEES MANAGER_ID
EMPLOYEES FIRST_NAME
EMPLOYEES LAST_NAME
EMPLOYEES TITLE
EMPLOYEES SALARY 員工薪水
SQL> select * from user_col_comments where comments is not null;
TABLE_NAME COLUMN_NAME COMMENTS
------------------------------ ------------------------------ -------------
EMPLOYEES SALARY 員工薪水
5.我們也可以從下面這些視圖中查看表級和列級說明:
ALL_COL_COMMENTS
USER_COL_COMMENTS
ALL_TAB_COMMENTS
USER_TAB_COMMENTS
6.刪除表級說明,也就是將其置為空
SQL> comment on table employees is '';
Comment added
SQL> select * from user_tab_comments where TABLE_NAME='EMPLOYEES';
TABLE_NAME TABLE_TYPE COMMENTS
------------------------------ ----------- -------------
EMPLOYEES TABLE
7.刪除列級說明,也是將其置為空
SQL> comment on column employees.salary is '';
Comment added
SQL> select * from user_col_comments where TABLE_NAME='EMPLOYEES';
TABLE_NAME COLUMN_NAME COMMENTS
------------------------------ ------------------------------ -------------
EMPLOYEES EMPLOYEE_ID
EMPLOYEES MANAGER_ID
EMPLOYEES FIRST_NAME
EMPLOYEES LAST_NAME
EMPLOYEES TITLE
EMPLOYEES SALARY
相關(guān)文章
oracle數(shù)據(jù)庫添加或刪除一列的sql語句
需要注意的一點,如果要修改的表,不是當前的用戶的表,那么就需要添加上用戶的名稱。以及有修改此表的權(quán)限2012-05-05
使用 Oracle 數(shù)據(jù)庫進行基于 JSON 的應用程序開發(fā)
本文檔概述了 Oracle Database 19c 和 21c 版本中包含的功能和增強功能以??及相關(guān)的 Oracle 技術(shù),以及為什么 Oracle Database 中的 JSON 功能非常適合滿足當今開發(fā)人員尋求文檔存儲來持久化、查詢和處理應用程序數(shù)據(jù)的需求,感興趣的朋友一起看看吧2025-04-04
win平臺oracle rman備份和刪除dg備庫歸檔日志腳本
本文介紹win平臺oracle rman備份和刪除dg備庫歸檔日志腳本2013-11-11

