Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a comment to an oracle database view

I would really like to create a comment to a view with a short description of its purpose. Unfortunately it is not possible to create comments to views in oracle. This feature is only for tables, columns and materialized views available. I would like to know how you do describe your database views?

like image 844
eglobetrotter Avatar asked May 15 '12 13:05

eglobetrotter


People also ask

How do I add a comment to a SQL view?

The single line SQL comment uses two dashes (–) in SQL Server. Once you add the two dashes, SQL Server ignores the text written after these dashes in a single line. It is known as commenting out. You can also see a different color in SQL Server Management Studio (SSMS) after you commented on a piece of code.

How do I view comments in Oracle?

You can view the comments on a particular table or column by querying the data dictionary views USER_TAB_COMMENTS , DBA_TAB_COMMENTS , or ALL_TAB_COMMENTS or USER_COL_COMMENTS , DBA_COL_COMMENTS , or ALL_COL_COMMENTS . Specify the name of the operator to be commented.


2 Answers

Try:

comment on table <name> is 'text';

The command works on views. For example:

CREATE OR REPLACE VIEW MY_VW AS
  SELECT 1 FROM DUAL;

COMMENT ON TABLE MY_VW IS 'Clever comment.';
like image 103
Raphaël Althaus Avatar answered Sep 29 '22 05:09

Raphaël Althaus


Its possible to create a comment on VIEWs too :

COMMENT ON TABLE view_name ;
like image 30
mcha Avatar answered Sep 29 '22 06:09

mcha