手机
当前位置:查字典教程网 >编程开发 >Oracle教程 >oracle comment命令用法示例分享
oracle comment命令用法示例分享
摘要:oracle中用commenton命令给表或字段加以说明,语法如下:复制代码代码如下:COMMENTON{TABLE[schema.]{ta...

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

【oracle comment命令用法示例分享】相关文章:

oracle 11g RAC 常用命令整理分享

oracle distinct 的使用方法

oracle 函数

Oracle中instr函数使用方法

oracle常用函数汇总(分享)

Oracle MERGE INTO的用法示例介绍

oracle 索引不能使用深入解析

oracle 安装与SQLPLUS简单用法

Oracle中返回结果集的存储过程分享

oracle命令行删除与创建用户的代码

精品推荐
分类导航