Skip to content

Commit ed1c166

Browse files
rmlovelandmdlinville
authored andcommitted
Update COMMENT ON docs for types (#18761)
* Add types to COMMENT ON docs for v24.2 Fixes DOC-10455, DOC-10572
1 parent b0c2191 commit ed1c166

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

src/current/v24.2/comment-on.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
title: COMMENT ON
3-
summary: The COMMENT ON statement associates comments to databases, tables, columns, or indexes.
3+
summary: The COMMENT ON statement associates comments to databases, tables, columns, indexes, or types.
44
toc: true
55
docs_area: reference.sql
66
---
77

8-
The `COMMENT ON` [statement]({% link {{ page.version.version }}/sql-statements.md %}) associates comments to [databases]({% link {{ page.version.version }}/create-database.md %}), [tables]({% link {{ page.version.version }}/create-table.md %}), [columns]({% link {{ page.version.version }}/alter-table.md %}#add-column), or [indexes]({% link {{ page.version.version }}/indexes.md %}).
8+
The `COMMENT ON` [statement]({% link {{ page.version.version }}/sql-statements.md %}) associates comments to [databases]({% link {{ page.version.version }}/create-database.md %}), [tables]({% link {{ page.version.version }}/create-table.md %}), [columns]({% link {{ page.version.version }}/alter-table.md %}#add-column), [indexes]({% link {{ page.version.version }}/indexes.md %}), or [types]({% link {{page.version.version}}/show-types.md %}).
99

1010
{% include {{ page.version.version }}/misc/schema-change-stmt-note.md %}
1111

@@ -25,6 +25,7 @@ The user must have the `CREATE` [privilege]({% link {{ page.version.version }}/s
2525
------------|--------------
2626
`database_name` | The name of the [database]({% link {{ page.version.version }}/create-database.md %}) on which you are commenting.
2727
`schema_name` | The name of the [schema]({% link {{ page.version.version }}/create-schema.md %}) on which you are commenting.
28+
`type_name` | The name of the [type]({% link {{ page.version.version }}/show-types.md %}) on which you are commenting.
2829
`table_name` | The name of the [table]({% link {{ page.version.version }}/create-table.md %}) on which you are commenting.
2930
`column_name` | The name of the [column]({% link {{ page.version.version }}/alter-table.md %}#add-column) on which you are commenting.
3031
`table_index_name` | The name of the [index]({% link {{ page.version.version }}/indexes.md %}) on which you are commenting.
@@ -180,6 +181,50 @@ To view column comments, use [`SHOW INDEXES ... WITH COMMENT`]({% link {{ page.v
180181
(8 rows)
181182
~~~
182183

184+
### Add a comment to a type
185+
186+
Issue a SQL statement to [create a type]({% link {{ page.version.version }}/create-type.md %}):
187+
188+
{% include_cached copy-clipboard.html %}
189+
~~~ sql
190+
CREATE TYPE IF NOT EXISTS my_point AS (x FLOAT, y FLOAT, z FLOAT);
191+
~~~
192+
193+
To view the type you just created, use [`SHOW TYPES`]({% link {{page.version.version}}/show-types.md %}):
194+
195+
{% include_cached copy-clipboard.html %}
196+
~~~ sql
197+
SHOW TYPES;
198+
~~~
199+
200+
~~~
201+
schema | name | owner
202+
---------+----------+--------
203+
public | my_point | root
204+
(1 row)
205+
~~~
206+
207+
To add a comment on the type, use a statement like the following:
208+
209+
{% include_cached copy-clipboard.html %}
210+
~~~ sql
211+
COMMENT ON TYPE my_point IS '3D point';
212+
~~~
213+
214+
To view all comments on types, make a [selection query]({% link {{page.version.version}}/select-clause.md %}) against the `system.comments` table:
215+
216+
{% include_cached copy-clipboard.html %}
217+
~~~ sql
218+
SELECT * FROM system.comments;
219+
~~~
220+
221+
~~~
222+
type | object_id | sub_id | comment
223+
-------+-----------+--------+-----------
224+
7 | 112 | 0 | 3D POINT
225+
(1 row)
226+
~~~
227+
183228
### Remove a comment from a database
184229

185230
To remove a comment from a database:
@@ -204,6 +249,15 @@ To remove a comment from a database:
204249
(4 rows)
205250
~~~
206251

252+
### Remove a comment from a type
253+
254+
To remove the comment from the type you created in the [preceding example](#add-a-comment-to-a-type), add a `NULL` comment:
255+
256+
{% include_cached copy-clipboard.html %}
257+
~~~ sql
258+
COMMENT ON TYPE my_point IS NULL;
259+
~~~
260+
207261
## See also
208262

209263
- [`CREATE DATABASE`]({% link {{ page.version.version }}/create-database.md %})

0 commit comments

Comments
 (0)