oracle comment on的用法
生活随笔
收集整理的這篇文章主要介紹了
oracle comment on的用法
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
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 ? ?
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 ? ?
總結(jié)
以上是生活随笔為你收集整理的oracle comment on的用法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: tkprof简称
- 下一篇: ORACLE sqlplus set 命