If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > comment in column definition

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-30-07, 10:53
krReddy krReddy is offline
Registered User
 
Join Date: Oct 2006
Posts: 83
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
Reply With Quote
  #2 (permalink)  
Old 04-30-07, 12:26
aschk aschk is offline
Registered User
 
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...
Reply With Quote
  #3 (permalink)  
Old 05-02-07, 06:20
krReddy krReddy is offline
Registered User
 
Join Date: Oct 2006
Posts: 83
How this comment keyword affects the result set.
Quote:
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.
Reply With Quote
  #4 (permalink)  
Old 05-02-07, 06:40
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
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:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #5 (permalink)  
Old 05-02-07, 06:41
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
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:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #6 (permalink)  
Old 05-02-07, 07:06
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 05-02-07, 07:12
krReddy krReddy is offline
Registered User
 
Join Date: Oct 2006
Posts: 83
consider it as varchar(24)
Reply With Quote
  #8 (permalink)  
Old 05-02-07, 07:35
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
wouldn't make any difference

the comment is just a comment, it has absolutely no effect on anything
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #9 (permalink)  
Old 05-02-07, 08:06
krReddy krReddy is offline
Registered User
 
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
Reply With Quote
  #10 (permalink)  
Old 05-02-07, 08:11
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by krReddy
... will that comment string appear
absolutely not
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #11 (permalink)  
Old 05-02-07, 08:12
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
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:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #12 (permalink)  
Old 05-02-07, 10:33
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
krReddy, have you bothered to make a test table and find out?
Reply With Quote
  #13 (permalink)  
Old 05-02-07, 12:56
krReddy krReddy is offline
Registered User
 
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.
Reply With Quote
  #14 (permalink)  
Old 05-02-07, 15:25
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
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.
Reply With Quote
  #15 (permalink)  
Old 05-02-07, 16:26
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On