---
title: "comment on table and column"
author: "unixboy"
date: "2009-11-20T16:16:07Z"
tags: ["Oracle", "SQL"]
slug: "comment-on-table-and-column"
draft: false
lastmod: "2009-11-20T16:16:07Z"
id: 521318
url: "https://unixboy.iteye.com/blog/521318"
---

comment \[Oracle SQL]  
       

comment on table  some\_table       is 'some hopefully meaningful comment for some\_table';  
comment on table  some\_view        is 'Views can also be commented, yet the statement is still: comment on table';  
comment on column some\_table.col\_1 is 'Be sure to really give some meaningful comment';  
comment on column some\_view.col\_1  is 'Useless, or wrong comments, are worse than no comment at all';

The comment statement allows to store some comments about tables, views or columns in the data dictionary.  
Even when views are commented, the syntax is comment on table.  
The comments for tables and views can be retrieved with something like

column comments format a50  
select table\_name, comments from user\_tab\_comments where table\_name like 'SOME%';

TABLE\_NAME                     COMMENTS  
\------------------------------ --------------------------------------------------  
SOME\_TABLE                     some hopefully meaningful comment for some\_table  
SOME\_VIEW                      Views can also be commented, yet the statement is  
                               still: comment on table

Similarly, the comments for columns can be found with something like

column comments format a50  
select table\_name, column\_name, comments from user\_col\_comments where table\_name like 'SOME%';

TABLE\_NAME                     COLUMN\_NAME                    COMMENTS  
\------------------------------ ------------------------------ --------------------------------------------------  
SOME\_TABLE                     COL\_1                          Be sure to really give some meaningful comment  
SOME\_TABLE                     COL\_2  
SOME\_TABLE                     COL\_3  
SOME\_VIEW                      COL\_1                          Useless, or wrong comments, are worse than no comm  
                                                              ent at all

SOME\_VIEW                      COL\_2  
SOME\_VIEW                      COL\_3

See also comments (PL/SQL).