COMMENT 中文man页面

系统
COMMENT 存储一个数据库对象的评注, 这个评注可以很容易用 psql 的 \dd, \d+, 和 \l+ 命令检索出来。 其它检索评注的用户接口可以建设在 psql 所用地同样地内部函数的基础上, 也就是 obj_description() 和 col_description()。

NAME

COMMENT - 定义或者改变一个对象的评注

SYNOPSIS

COMMENT ON
{
  TABLE object_name |
  COLUMN table_name.column_name |
  AGGREGATE agg_name (agg_type) |
  CONSTRAINT constraint_name ON table_name |
  DATABASE object_name |
  DOMAIN object_name |
  FUNCTION func_name (arg1_type, arg2_type, ...) |
  INDEX object_name |
  OPERATOR op (leftoperand_type, rightoperand_type) |
  RULE rule_name ON table_name |
  SCHEMA object_name |
  SEQUENCE object_name |
  TRIGGER trigger_name ON table_name |
  TYPE object_name |
  VIEW object_name
} IS 'text'

DESCRIPTION 描述

COMMENT 存储一个数据库对象的评注, 这个评注可以很容易用 psql 的 \dd, \d+, 和 \l+ 命令检索出来。 其它检索评注的用户接口可以建设在 psql 所用地同样地内部函数的基础上, 也就是 obj_description() 和 col_description()。


 要修改一个评注,为同一个对象发出一条新的 COMMENT 命令即可。每个对象只存储一条评注。 要删除评注,在文本字串的位置写上 NULL。 当删除对象时,评注自动被删除掉。  

PARAMETERS 参数

object_name
table_name.column_name
aggname
constraint_name
func_name
op
rule_name
trigger_name

 要加入评注的对象名称。表,索引,序列,视图,类型,域,函数, 聚集和操作符的名字可以是模式修饰的。
agg_type
聚集函数的参数类型,如果函数接受任意数据类型,那么是 *。
large_object_oid
大对象的 OID。
PROCEDURAL
这个字无用。
sourcetype
类型转换的源数据类型名字。
targettype
类型转换的目的数据类型名字。
text
新的评注。

NOTES 注意


 一个数据库里的评注只能在改数据库里创建,并且只有在那个数据库里可见,其它库里不可见。
 
 需要说明的是目前评注没有安全机制:任何联接到某数据库上的用户都可以看到所有该数据库对象的评注 (尽管只有超级用户可以修改不属于他的对象的评注)。因此,不要在评注里放安全性敏感地信息。  

EXAMPLES 例子


 给表mytable 加评注:

COMMENT ON TABLE mytable IS 'This is my table.';


 再删除它:

COMMENT ON TABLE mytable IS NULL;


 一些例子:

COMMENT ON AGGREGATE my_aggregate (double precision) IS 'Computes sample variance';
COMMENT ON COLUMN my_table.my_column IS 'Employee ID number';
COMMENT ON DATABASE my_database IS 'Development Database';
COMMENT ON DOMAIN my_domain IS 'Email Address Domain';
COMMENT ON FUNCTION my_function (timestamp) IS 'Returns Roman Numeral';
COMMENT ON INDEX my_index IS 'Enforces uniqueness on employee ID';
COMMENT ON OPERATOR ^ (text, text) IS 'Performs intersection of two texts';
COMMENT ON OPERATOR ^ (NONE, text) IS 'This is a prefix operator on text';
COMMENT ON RULE my_rule ON my_table IS 'Logs updates of employee records';
COMMENT ON SCHEMA my_schema IS 'Departmental data';
COMMENT ON SEQUENCE my_sequence IS 'Used to generate primary keys';
COMMENT ON TABLE my_schema.my_table IS 'Employee Information';
COMMENT ON TRIGGER my_trigger ON my_table IS 'Used for RI';
COMMENT ON TYPE complex IS 'Complex number data type';
COMMENT ON VIEW my_view IS 'View of departmental costs';

#p#

NAME

COMMENT - define or change the comment of an object

SYNOPSIS

COMMENT ON
{
  TABLE object_name |
  COLUMN table_name.column_name |
  AGGREGATE agg_name (agg_type) |
  CONSTRAINT constraint_name ON table_name |
  DATABASE object_name |
  DOMAIN object_name |
  FUNCTION func_name (arg1_type, arg2_type, ...) |
  INDEX object_name |
  OPERATOR op (leftoperand_type, rightoperand_type) |
  RULE rule_name ON table_name |
  SCHEMA object_name |
  SEQUENCE object_name |
  TRIGGER trigger_name ON table_name |
  TYPE object_name |
  VIEW object_name
} IS 'text'

DESCRIPTION

COMMENT stores a comment about a database object. Comments can be easily retrieved with the psql commands \dd, \d+, and \l+. Other user interfaces to retrieve comments can be built atop the same built-in functions that psql uses, namely obj_description and col_description.

To modify a comment, issue a new COMMENT command for the same object. Only one comment string is stored for each object. To remove a comment, write NULL in place of the text string. Comments are automatically dropped when the object is dropped.  

PARAMETERS

object_name
table_name.column_name
aggname
constraint_name
func_name
op
rule_name
trigger_name
The name of the object to be be commented. Names of tables, aggregates, domains, functions, indexes, operators, sequences, types, and views may be schema-qualified.
text
The new comment.

NOTES

There is presently no security mechanism for comments: any user connected to a database can see all the comments for objects in that database (although only superusers can change comments for objects that they don't own). Therefore, don't put security-critical information in comments.  

EXAMPLES

Attach a comment to the table mytable:

COMMENT ON TABLE mytable IS 'This is my table.';

Remove it again:

COMMENT ON TABLE mytable IS NULL;

Some more examples:

COMMENT ON AGGREGATE my_aggregate (double precision) IS 'Computes sample variance';
COMMENT ON COLUMN my_table.my_column IS 'Employee ID number';
COMMENT ON DATABASE my_database IS 'Development Database';
COMMENT ON DOMAIN my_domain IS 'Email Address Domain';
COMMENT ON FUNCTION my_function (timestamp) IS 'Returns Roman Numeral';
COMMENT ON INDEX my_index IS 'Enforces uniqueness on employee ID';
COMMENT ON OPERATOR ^ (text, text) IS 'Performs intersection of two texts';
COMMENT ON OPERATOR ^ (NONE, text) IS 'This is a prefix operator on text';
COMMENT ON RULE my_rule ON my_table IS 'Logs updates of employee records';
COMMENT ON SCHEMA my_schema IS 'Departmental data';
COMMENT ON SEQUENCE my_sequence IS 'Used to generate primary keys';
COMMENT ON TABLE my_schema.my_table IS 'Employee Information';
COMMENT ON TRIGGER my_trigger ON my_table IS 'Used for RI';
COMMENT ON TYPE complex IS 'Complex number data type';
COMMENT ON VIEW my_view IS 'View of departmental costs';

责任编辑:韩亚珊 来源: CMPP.net
相关推荐

2011-08-24 16:48:36

man中文man

2011-08-15 10:21:09

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-11-01 13:46:50

中文mantac

2011-08-25 16:55:26

gets中文man

2011-08-25 17:18:07

putc中文man

2011-08-25 15:49:02

freopen中文man

2011-08-25 16:00:56

fflush中文man

2011-08-25 16:08:55

fsetpos中文man

2011-08-25 15:24:31

execlp中文man

2011-08-25 15:33:18

exit中文man

2011-08-15 10:00:08

lsattr中文man

2011-08-24 17:19:00

raw中文man

2011-08-25 10:55:37

services中文man

2011-08-25 09:35:26

units中文man

2011-08-24 16:16:07

LISTEN中文man

2011-08-24 13:57:35

DECLARE中文man

2011-08-11 15:28:43

ali中文man

2011-08-16 10:10:58

setup中文man
点赞
收藏

51CTO技术栈公众号