Creating comments on column using "Execute immediate"

posted Mar 23, 2012, 12:47 AM by Sachchida Ojha   [ updated Mar 23, 2012, 12:50 AM ]


[oracle@usha ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri Mar 23 03:05:50 2012

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> desc test;
 Name                       Null?    Type
 ----------------------------------------- -------- ----------------------------
 NAME                            VARCHAR2(128)


SQL> set define off
SQL> comment on column test.name is 'sachi''s home & graden';

Comment created.

SQL> select table_name,column_name,comments from USER_COL_COMMENTS where table_name='TEST';

TABLE_NAME               COLUMN_NAME
------------------------------ ------------------------------
COMMENTS
--------------------------------------------------------------------------------
TEST                   NAME
sachi's home & graden


SQL> begin
  2  execute immediate 'comment on column test.name is ''sachi''''s home & graden''';
  3  end;
  4  /

PL/SQL procedure successfully completed.

SQL> select table_name,column_name,comments from USER_COL_COMMENTS where table_name='TEST';

TABLE_NAME               COLUMN_NAME
------------------------------ ------------------------------
COMMENTS
--------------------------------------------------------------------------------
TEST                   NAME
sachi's home & graden


SQL>

SQL> begin
  2  execute immediate 'comment on column test.name is ''sachi home & graden''';
  3  end;
  4  /

PL/SQL procedure successfully completed.

SQL> select table_name,column_name,comments from USER_COL_COMMENTS where table_name='TEST';

TABLE_NAME               COLUMN_NAME
------------------------------ ------------------------------
COMMENTS
--------------------------------------------------------------------------------
TEST                   NAME
sachi home & graden


SQL> begin
  2  execute immediate 'comment on column test.name is ''sachi''''s home & graden''';
  3  end;
  4  /

PL/SQL procedure successfully completed.

SQL> select table_name,column_name,comments from USER_COL_COMMENTS where table_name='TEST';

TABLE_NAME               COLUMN_NAME
------------------------------ ------------------------------
COMMENTS
--------------------------------------------------------------------------------
TEST                   NAME
sachi's home & graden


SQL>



Comments