Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Join Date
    Oct 2006
    Posts
    83

    Unanswered: comment in column definition

    In the below query
    please tell me what the comment key word will do .

    CREATE TABLE temp2 (
    type21 varchar(1) default NULL COMMENT 'F: Female M:Male')

    I am trying to generate the equivalent for the above query in MSSQL Server . If i know what exactly it does , then it will be easy for me to generate the similar query in SQL Server

    PLZ help me out

  2. #2
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    All it does it allow you to place some "meaningful" information in your MySQL table. It can help (in the example you have given) someone understand what the column is for and what values it should have.

    If you want the MSSQL equivalent you should ask in the MSSQL forum...

  3. #3
    Join Date
    Oct 2006
    Posts
    83
    How this comment keyword affects the result set.
    CREATE TABLE temp2 (
    type21 varchar(1) default NULL COMMENT 'F: Female M:Male')
    I have exected the above query And inserted some values. Please tell me how the comment key word will make difference to the result set.

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by aschk
    If you want the MSSQL equivalent you should ask in the MSSQL forum...
    To be fair - he did do. And my response was "what does that mean in English? This is the MSSQL forum - go ask the MySQL guys what it means in the first place then we can try to translate"
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by aschk
    All it does it allow you to place some "meaningful" information in your MySQL table. It can help (in the example you have given) someone understand what the column is for and what values it should have.
    What is displayed to the user? 'm' or 'male'?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by pootle flump
    What is displayed to the user? 'm' or 'male'?
    it'd be pretty difficult to pull 'male' out of a VARCHAR(1) column

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  7. #7
    Join Date
    Oct 2006
    Posts
    83
    consider it as varchar(24)

  8. #8
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    wouldn't make any difference

    the comment is just a comment, it has absolutely no effect on anything
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  9. #9
    Join Date
    Oct 2006
    Posts
    83
    is that comment will be displayed in the table .
    I mean if we create a table with a comment defined , and after inserting the values to it, Then if we display the table(Select * from temp2) ,will that comment string appear

  10. #10
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by krReddy
    ... will that comment string appear
    absolutely not
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  11. #11
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by r937
    it'd be pretty difficult to pull 'male' out of a VARCHAR(1) column

    Note I said what is displayed .

    Anyway - Kr - your answer for converting to SQL is you can create a description for the column as demonstrated in the other thread. This will have no affect on the data (constraints etc). I presume the same is true here.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  12. #12
    Join Date
    Mar 2004
    Posts
    480
    krReddy, have you bothered to make a test table and find out?

  13. #13
    Join Date
    Oct 2006
    Posts
    83
    I have tried it, but the comment is nowhere displayed in the table .
    But when i execute 'SHOW FULL COLUMNS FROM TEMP2' ,its being present in comment field.

  14. #14
    Join Date
    Mar 2004
    Posts
    480
    okay so exactly what are you trying to do? a comment is never displayed in your table unless you explicitly do so either with the show full columns, or show create table or whatever. at no other time do you see a comment for a field.

    do you really want a default value for a column or something like that or are you merely trying to understand how comments work?

    in your case under a column called SEX for instance, a comment may not be necessary if you only use M or F to represent, but what if you also included T for transgendered for instance. then a comment would make sense because if you were to go back to the table at some distant time, or turn the application over to someone else, the comment would make it clear exactly what the reason for T being in that column was.

  15. #15
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by guelphdad
    in your case under a column called SEX for instance, a comment may not be necessary if you only use M or F to represent, but what if you also included T for transgendered for instance. then a comment would make sense because if you were to go back to the table at some distant time, or turn the application over to someone else, the comment would make it clear exactly what the reason for T being in that column was.
    i would use a foreign key to a proper domain table instead

    the data is the documentation
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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