https://blog.csdn.net/DaisyLoveZly/article/details/77503502
oracle comment on的用法
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
下面我展示一下項目開發中的實例來做參考
-- Create table
create table F_S_WASH_TASK
(
task_id NUMBER(16) not null,
task_no VARCHAR2(16) not null,
equip_categ VARCHAR2(8),
task_status VARCHAR2(8) not null,
start_date DATE not null,
end_date DATE,
task_num NUMBER(15),
org_no VARCHAR2(16) not null,
creator_no VARCHAR2(16),
create_date DATE,
exec_org_no VARCHAR2(16),
team_no VARCHAR2(16),
executor_no VARCHAR2(16),
parent_task_id NUMBER,
priority VARCHAR2(8) not null,
remark VARCHAR2(32),
finish_remark VARCHAR2(256),
wiring_mode VARCHAR2(8),
finished_date DATE,
real_start_date DATE
)
tablespace MPAC_A
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64
next 1
minextents 1
maxextents unlimited
);
-- Add comments to the table
comment on table F_S_WASH_TASK
is '清潔分選任務表';
-- Add comments to the columns
comment on column F_S_WASH_TASK.task_id
is '唯一標識';
comment on column F_S_WASH_TASK.task_no
is '清潔分選任務編';
comment on column F_S_WASH_TASK.equip_categ
is '設備類別,參見計量標准代碼:設備類別VW_EQUIP_CATEG';
comment on column F_S_WASH_TASK.task_status
is '任務狀態,01初始、02待分配、03已分配、04執行中、05執行完成、06已完成';
comment on column F_S_WASH_TASK.start_date
is '任務開始時間';
comment on column F_S_WASH_TASK.end_date
is '任務結束時間';
comment on column F_S_WASH_TASK.task_num
is '任務數量';
comment on column F_S_WASH_TASK.org_no
is '創建單位編號';
comment on column F_S_WASH_TASK.creator_no
is '創建人';
comment on column F_S_WASH_TASK.create_date
is '創建時間';
comment on column F_S_WASH_TASK.exec_org_no
is '執行單位';
comment on column F_S_WASH_TASK.team_no
is '執行班組';
comment on column F_S_WASH_TASK.executor_no
is '執行人';
comment on column F_S_WASH_TASK.parent_task_id
is '父任務標識';
comment on column F_S_WASH_TASK.priority
is '任務優先級 01一般 02 重要 03緊急';
comment on column F_S_WASH_TASK.remark
is '備注';
comment on column F_S_WASH_TASK.finish_remark
is '任務完成備注';
comment on column F_S_WASH_TASK.wiring_mode
is '接線方式';
comment on column F_S_WASH_TASK.finished_date
is '任務完成日期';
comment on column F_S_WASH_TASK.real_start_date
is '任務實際開始時間';
-- Create/Recreate primary, unique and foreign key constraints
alter table F_S_WASH_TASK
add constraint PK_F_S_WASH_TASK primary key (TASK_ID)
using index
tablespace MPAC_A
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
next 1M
minextents 1
maxextents unlimited
);
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95