How to add caption to a table in Oracle using sql?

by Surender

We have no idea what captions are in relation to Oracle. A search on and on the Oracle Technology Network (including all the documentation) did not show anything that might be relevant.

We can only assume (with a little lateral thinking) that your are referring to comments about tables, columns, views, editions (from 11g onwards), operators, and indextypes in the Oracle database. Table comments are stored in ALL/USER/DBA_TAB_COMMENTS and column comments are stored in ALL/USER/DBA_COL_COMMENTS. The other types of comments are stored in their respective ALL/USER/DBA_<object type>_COMMENTS tables which can be queried in the same way as any other table. These comments add to the database meta data and are used to provide additional information about the tables, columns and views etc. you create in your Oracle database.

Adding comments for a table, column, view etc is simply a matter of using the SQL COMMENT ON statement, specifying the type of object (table, column, view, etc) as well as the object name and for a column the name of the owning table or view.

For example to add a comment on your table "emp" the SQL command would be:

COMMENT ON TABLE emp IS 'copy of employees table but without the foreign key constraints';.

The exact syntax of the COMMENT ON statement can be found in the Oracle Database SQL Language Reference 11g Release 2 (11.2).

For more help with SQL see our Oracle SQL tutorial.

If you're interested in formal Oracle training (either on-line or in a classroom) then see our Oracle training page for more information.

Click here to post comments

Join in and write your own page! It's easy to do. How? Simply click here to return to Oracle Questions.