The COMMENT ON statement allows adding metadata to catalog entries (tables, columns, etc.). It follows the PostgreSQL syntax.
COMMENT ON
Create a comment on a TABLE:
TABLE
COMMENT ON TABLE test_table IS 'very nice table';
Create a comment on a COLUMN:
COLUMN
COMMENT ON COLUMN test_table.test_table_column IS 'very nice column';
Create a comment on a VIEW:
VIEW
COMMENT ON VIEW test_view IS 'very nice view';
Create a comment on an INDEX:
INDEX
COMMENT ON INDEX test_index IS 'very nice index';
Create a comment on a SEQUENCE:
SEQUENCE
COMMENT ON SEQUENCE test_sequence IS 'very nice sequence';
Create a comment on a TYPE:
TYPE
COMMENT ON TYPE test_type IS 'very nice type';
Create a comment on a MACRO:
MACRO
COMMENT ON MACRO test_macro IS 'very nice macro';
Create a comment on a MACRO TABLE:
MACRO TABLE
COMMENT ON MACRO TABLE test_table_macro IS 'very nice table macro';
To unset a comment, set it to NULL, e.g.:
NULL
COMMENT ON TABLE test_table IS NULL;
Comments can be read by querying the comment column of the respective metadata functions:
comment
List comments on TABLEs:
SELECT comment FROM duckdb_tables();
List comments on COLUMNs:
SELECT comment FROM duckdb_columns();
List comments on VIEWs:
SELECT comment FROM duckdb_views();
List comments on INDEXs:
SELECT comment FROM duckdb_indexes();
List comments on SEQUENCEs:
SELECT comment FROM duckdb_sequences();
List comments on TYPEs:
SELECT comment FROM duckdb_types();
List comments on MACROs:
SELECT comment FROM duckdb_functions();
List comments on MACRO TABLEs:
The COMMENT ON statement currently has the following limitations:
COMMENT ON Statement
The
COMMENT ONstatement allows adding metadata to catalog entries (tables, columns, etc.). It follows the PostgreSQL syntax.Examples
Create a comment on a
TABLE:Create a comment on a
COLUMN:Create a comment on a
VIEW:Create a comment on an
INDEX:Create a comment on a
SEQUENCE:Create a comment on a
TYPE:Create a comment on a
MACRO:Create a comment on a
MACRO TABLE:To unset a comment, set it to
NULL, e.g.:Reading Comments
Comments can be read by querying the
commentcolumn of the respective metadata functions:List comments on
TABLEs:List comments on
COLUMNs:List comments on
VIEWs:List comments on
INDEXs:List comments on
SEQUENCEs:List comments on
TYPEs:List comments on
MACROs:List comments on
MACRO TABLEs:Limitations
The
COMMENT ONstatement currently has the following limitations:Syntax
In this article