You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/current/v24.2/comment-on.md
+56-2Lines changed: 56 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
---
2
2
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.
4
4
toc: true
5
5
docs_area: reference.sql
6
6
---
7
7
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 %}).
9
9
10
10
{% include {{ page.version.version }}/misc/schema-change-stmt-note.md %}
11
11
@@ -25,6 +25,7 @@ The user must have the `CREATE` [privilege]({% link {{ page.version.version }}/s
25
25
------------|--------------
26
26
`database_name` | The name of the [database]({% link {{ page.version.version }}/create-database.md %}) on which you are commenting.
27
27
`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.
28
29
`table_name` | The name of the [table]({% link {{ page.version.version }}/create-table.md %}) on which you are commenting.
29
30
`column_name` | The name of the [column]({% link {{ page.version.version }}/alter-table.md %}#add-column) on which you are commenting.
30
31
`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
180
181
(8 rows)
181
182
~~~
182
183
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
+
CREATETYPEIF 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*FROMsystem.comments;
219
+
~~~
220
+
221
+
~~~
222
+
type | object_id | sub_id | comment
223
+
-------+-----------+--------+-----------
224
+
7 | 112 | 0 | 3D POINT
225
+
(1 row)
226
+
~~~
227
+
183
228
### Remove a comment from a database
184
229
185
230
To remove a comment from a database:
@@ -204,6 +249,15 @@ To remove a comment from a database:
204
249
(4 rows)
205
250
~~~
206
251
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
+
207
261
## See also
208
262
209
263
-[`CREATE DATABASE`]({% link {{ page.version.version }}/create-database.md %})
0 commit comments