Search Shortcut cmd + k | ctrl + k
Search cmd+k ctrl+k
1.0 (stable)
COMMENT ON Statement

The COMMENT ON statement allows adding metadata to catalog entries (tables, columns, etc.). It follows the PostgreSQL syntax.

Examples

Create a comment on a TABLE:

COMMENT ON TABLE test_table IS 'very nice table';

Create a comment on a COLUMN:

COMMENT ON COLUMN test_table.test_table_column IS 'very nice column';

Create a comment on a VIEW:

COMMENT ON VIEW test_view IS 'very nice view';

Create a comment on an INDEX:

COMMENT ON INDEX test_index IS 'very nice index';

Create a comment on a SEQUENCE:

COMMENT ON SEQUENCE test_sequence IS 'very nice sequence';

Create a comment on a TYPE:

COMMENT ON TYPE test_type IS 'very nice type';

Create a comment on a MACRO:

COMMENT ON MACRO test_macro IS 'very nice macro';

Create a comment on a MACRO TABLE:

COMMENT ON MACRO TABLE test_table_macro IS 'very nice table macro';

To unset a comment, set it to NULL, e.g.:

COMMENT ON TABLE test_table IS NULL;

Reading Comments

Comments can be read by querying the comment column of the respective metadata functions:

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:

SELECT comment FROM duckdb_functions();

Limitations

The COMMENT ON statement currently has the following limitations:

  • It is not possible to comment on schemas or databases.
  • It is not possible to comment on things that have a dependency (e.g., a table with an index).

Syntax

About this page

Last modified: 2024-07-16