Search Shortcut cmd + k | ctrl + k
v0.10.0 (stable)
COMMENT ON Statement

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

Examples

COMMENT ON TABLE test_table IS 'very nice table';
COMMENT ON COLUMN test_table.test_table_column IS 'very nice column';
COMMENT ON VIEW test_view IS 'very nice view';
COMMENT ON INDEX test_index IS 'very nice index';
COMMENT ON SEQUENCE test_sequence IS 'very nice sequence';
COMMENT ON TYPE test_type IS 'very nice type';
COMMENT ON MACRO test_macro IS 'very nice macro';
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:

SELECT comment FROM duckdb_tables();    -- TABLE
SELECT comment FROM duckdb_columns();   -- COLUMN
SELECT comment FROM duckdb_views();     -- VIEW
SELECT comment FROM duckdb_indexes();   -- INDEX
SELECT comment FROM duckdb_sequences(); -- SEQUENCE
SELECT comment FROM duckdb_types();     -- TYPE
SELECT comment FROM duckdb_functions(); -- MACRO
SELECT comment FROM duckdb_functions(); -- MACRO TABLE

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-02-24