Results 1 to 10 of 10
  1. #1
    Join Date
    Jan 2003
    Posts
    16

    Unanswered: comment on column

    When I create tables, I want to add comments to the columns. I know there is a sql statement COMMENT ON to add comments to columns. Expect for that statement, how can add comment when creating tables? I tried the following:
    create table temp_tbl
    (col1 integer,
    col2 integer comment is "col2 desc");
    and when executing the above sql statement, the systax error was returned. Any clue? Thanks for your help!

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    Re: comment on column

    I could be wrong ... AFAIk, there is no option to comment a column when creating a table

    Cheers

    Sathyaram

    Originally posted by dbques
    When I create tables, I want to add comments to the columns. I know there is a sql statement COMMENT ON to add comments to columns. Expect for that statement, how can add comment when creating tables? I tried the following:
    create table temp_tbl
    (col1 integer,
    col2 integer comment is "col2 desc");
    and when executing the above sql statement, the systax error was returned. Any clue? Thanks for your help!

  3. #3
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    I checked the syntax for CREATE TABLE and there is no way to add the comment of a column in that statement. If you want to comment columns, or the table you need to issue the COMMENT ON command after table creation/alteration.

    examples:
    create table mytab (col1 int, col2 char(10)) in mytablespace;
    comment on table mytab is 'This is my table';
    comment on column mytab.col1 is 'This is column 1';
    comment on column mytab;col2 is 'This is column 2';

    alter table mytab add column col3 varchar(40);
    comment on column mytab.col3 is 'This is column 3';

    HTH

    Andy

  4. #4
    Join Date
    Aug 2011
    Posts
    10

    hi

    [QUOTE=ARWinner;2606048]I checked the syntax for CREATE TABLE and there is no way to add the comment of a column in that statement. If you want to comment columns, or the table you need to issue the COMMENT ON command after table creation/alteration.

    examples:
    create table mytab (col1 int, col2 char(10)) in mytablespace;
    comment on table mytab is 'This is my table';
    comment on column mytab.col1 is 'This is column 1';
    comment on column mytab;col2 is 'This is column 2';

    alter table mytab add column col3 varchar(40);
    comment on column mytab.col3 is 'This is column 3';

    HTH
    Andy[/QUOTE

    thanks for the post andy.
    I doubt that where can we see these comments?
    i used describe table with show detail option, but i did not work.

  5. #5
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Thanks for resurrecting a nearly 9 year old topic. Do you have a specific question?

    Andy

  6. #6
    Join Date
    Aug 2011
    Posts
    10

    hi

    Quote Originally Posted by ARWinner View Post
    Thanks for resurrecting a nearly 9 year old topic. Do you have a specific question?

    Andy
    Andy

    I have a bunch of questions. I need your help to resolve my issues.

    Well, I am trying to interpret some of the syscat tables to an understandable format.

    e.g., syscat.functions table
    I observed singe character columns in this table(origin,type, method,effect, etc...). How would I interpret these type of columns ("data on metadata" would be appropriate).

    Another one is,
    While creating a table, we can comments(description) on columns(may be on table also). Where can I see these comments?

    thank you

  7. #7
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Quote Originally Posted by jagdis_vishnu View Post
    Andy

    I have a bunch of questions. I need your help to resolve my issues.

    Well, I am trying to interpret some of the syscat tables to an understandable format.

    e.g., syscat.functions table
    I observed singe character columns in this table(origin,type, method,effect, etc...). How would I interpret these type of columns ("data on metadata" would be appropriate).

    Another one is,
    While creating a table, we can comments(description) on columns(may be on table also). Where can I see these comments?

    thank you
    The DB2 catalog views are documented in the Appendix of the SQL Reference, Vol 1, which can be downloaded for free from the IBM website.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  8. #8
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    I agree with Marcus. You really should start with reading the manuals. Then if you have any specific questions, you can ask here.

    Andy

  9. #9
    Join Date
    Jan 2012
    Posts
    1
    Any video tutorials here?

  10. #10
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Quote Originally Posted by flogger123 View Post
    Any video tutorials here?
    Creating tables with comments is pretty basic stuff, no matter which DBMS system you are using. The manuals basically tell you how DB2 does it (which is fairly much the standard way to do it). They are far more in depth than any video could be.

    Andy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •