Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Databases - Practical PostgreSQL
Previous Page Home Next Page

COMMENT

Name

COMMENT -- Adds a comment to an object within the database.

Synopsis

COMMENT ON
[
  [ DATABASE | INDEX | RULE | SEQUENCE | TABLE | TYPE | VIEW ] 
object_name
 |
  COLUMN 
table_name
.
column_name
 |
  FUNCTION 
func_name
 ( 
argument
 [, ...] ) |
  AGGREGATE 
aggr_func
 
aggr_type
 |
  OPERATOR 
operator
 ( 
left_type
 , 
right_type
 ) |
  TRIGGER 
trigger_name
 ON 
table_name

] IS 
'text'

Parameters

DATABASE | INDEX | RULE | SEQUENCE | TABLE | TYPE | VIEW

The type of database object that you are adding a comment to.

object_name

The name of the object (database, index, rule, sequence, table, type, or view) to which you are adding a comment.

COLUMN table_name.column_name

The column name within table_name you are adding a comment to.

FUNCTION func_name ( argument [, ...] )

The name of the function on which you are commenting, specified also by the argument data types that it accepts.

AGGREGATE aggr_func aggr_type

The aggregate function name (and associated data type aggr_type , which it accepts) to which you are adding a comment.

OPERATOR operator ( left_type , right_type )

The name of the operator on which you are commenting ( operator ), further described by the data type it operates on to the left, and the data type it operates on to the right, separated by a comma, enclosed within parentheses. If either side is inapplicable, the NONE keyword may be used.

TRIGGER trigger_name ON table_name

The name of the trigger on which you are placing a comment, and the name of the table upon which the trigger is placed.

text

The actual text of the comment to add.

Results

COMMENT

The message returned when an object is successfully commented.

Description

COMMENT is a PostgreSQL-specific command that allows you to add comments to most objects within a database, including a database itself. Comments can be retrieved by using the following commands from within the psql client:

\l+

Displays all databases available, with comments.

\dd

Displays all database objects, with comments.

\d+

Displays all database objects in the connected database, with comments.

\dt+

Displays all tables in the connected database, with comments.

\di+

Displays all indices in the connected database, with comments.

\ds+

Displays all sequences in the connected database, with comments.

\dv+

Displays all views in the connected database, with comments.

\df+

Displays all functions in the connected database, with comments.

\da+

Displays all aggregate functions in the connected database, with comments.

\do+

Displays all operators in the connected database, with comments.

\dT+

Displays all data types in the connected database, with comments.

You can remove a comment by setting its text to NULL.

Note: A comment that has been made on an object will be removed when that object is removed from the system.

Examples

The following example adds a comment to the customers table:

booktown=# 
COMMENT ON TABLE customers IS 'For customer names.';

COMMENT

The next example deletes the previously added comment from the customer table:

booktown=# 
COMMENT ON TABLE customers IS NULL
;
Databases - Practical PostgreSQL
Previous Page Home Next Page

 
 
  Published under the terms of the Open Publication License Design by Interspire