5.18. Comments
Database objects and a database itself may be annotated with comments.
It is a convenient mechanism for documenting the development and maintenance of a database.
Comments created with COMMENT ON
will survive a gbak backup and restore.
5.18.1. COMMENT ON
Used forDocumenting metadata
Available inDSQL
Syntax
|
COMMENT ON <object> IS {'sometext' | NULL}
|
|<object> ::=
| {DATABASE | SCHEMA}
| | <basic-type> objectname
| | COLUMN relationname.fieldname
| | [{PROCEDURE | FUNCTION}] PARAMETER
| [packagename.]routinename.paramname
| | {PROCEDURE | [EXTERNAL] FUNCTION}
| [package_name.]routinename
|
|<basic-type> ::=
| CHARACTER SET | COLLATION | DOMAIN
| | EXCEPTION | FILTER | GENERATOR
| | INDEX | PACKAGE | ROLE
| | SEQUENCE | TABLE | TRIGGER
| | USER | VIEW
COMMENT ON
Statement ParametersParameter | Description |
---|---|
sometext | Comment text |
basic-type | Metadata object type |
objectname | Metadata object name |
relationname | Name of table or view |
fieldname | Name of the column |
package_name | Name of the package |
routinename | Name of stored procedure or function |
paramname | Name of a stored procedure or function parameter |
The COMMENT ON
statement adds comments for database objects (metadata).
Comments are saved to the RDB$DESCRIPTION
column of the corresponding system tables.
Client applications can view comments from these fields.
If you add an empty comment (
), it will be saved as''
NULL
in the database.The
COMMENT ON USER
statement will only create comments on users managed by the default usermanager (the first plugin listed in theUserManager
config option). See also CORE-6479.Comments on users are stored in the security database.
SCHEMA
is currently a synonym forDATABASE
; this may change in a future version, so we recommend to always useDATABASE
Comments on users are visible to that user through the SEC$USERS
virtual table.
5.18.1.1. Who Can Add a Comment
The COMMENT ON
statement can be executed by:
The owner of the object that is commented on
Users with the
ALTER ANY object_type
privilege, where object_type is the type of object commented on (e.g.PROCEDURE
)
5.18.1.2. Examples using COMMENT ON
Adding a comment for the current database
|
COMMENT ON DATABASE IS 'It is a test (''my.fdb'') database';
Adding a comment for the
METALS
table|
COMMENT ON TABLE METALS IS 'Metal directory';
Adding a comment for the
ISALLOY
field in theMETALS
table|
COMMENT ON COLUMN METALS.ISALLOY IS '0 = fine metal, 1 = alloy';
Adding a comment for a parameter
|
COMMENT ON PARAMETER ADD_EMP_PROJ.EMP_NO IS 'Employee ID';
Adding a comment for a package, its procedures and functions, and their parameters
|
COMMENT ON PACKAGE APP_VAR IS 'Application Variables';
|COMMENT ON FUNCTION APP_VAR.GET_DATEBEGIN
|IS 'Returns the start date of the period';
|COMMENT ON PROCEDURE APP_VAR.SET_DATERANGE
|IS 'Set date range';
|COMMENT ON
|PROCEDURE PARAMETER APP_VAR.SET_DATERANGE.ADATEBEGIN
|IS 'Start Date';