COMMENT

Name

COMMENT — 给一个对象增加评注
COMMENT ON
[
  [ DATABASE | INDEX | RULE | SEQUENCE | TABLE | TYPE | VIEW ]
  object_name |
  COLUMN table_name.column_name|
  AGGREGATE agg_name agg_type|
  FUNCTION func_name (arg1, arg2, ...)|
  OPERATOR op (leftoperand_type rightoperand_type) |
  TRIGGER trigger_name ON table_name
] IS 'text'
  

输入

object_name, table_name, column_name, agg_name, func_name, op, trigger_name

要加入评注的对象名称.

text

要加入的评注.

输出

COMMENT

成功对表评注后的返回.

描述

COMMENT 向一个对象里增加评注,这个评注可以很容易用 psql 的 \dd\d+ 命令检索出来. 要删除一个评注,使用 NULL. 当删除对象时,评注自动被删除掉.

用法

给表mytable 加评注:

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

一些例子:

COMMENT ON DATABASE my_database IS 'Development Database';
COMMENT ON INDEX my_index IS 'Enforces uniqueness on employee id';
COMMENT ON RULE my_rule IS 'Logs UPDATES of employee records';
COMMENT ON SEQUENCE my_sequence IS 'Used to generate primary keys';
COMMENT ON TABLE my_table IS 'Employee Information';
COMMENT ON TYPE my_type IS 'Complex Number support';
COMMENT ON VIEW my_view IS 'View of departmental costs';
COMMENT ON COLUMN my_table.my_field IS 'Employee ID number';
COMMENT ON AGGREGATE my_aggregate (double precision) IS 'Computes sample variance';
COMMENT ON FUNCTION my_function (timestamp) IS 'Returns Roman Numeral';
COMMENT ON OPERATOR ^ (text, text) IS 'Performs intersection of two text';
COMMENT ON TRIGGER my_trigger ON my_table IS 'Used for R.I.';
   

兼容性

SQL92

SQL92里没有COMMENT