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 > varchar or char

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-20-05, 01:47
popskie popskie is offline
Registered User
 
Join Date: Oct 2004
Location: In cousin's house
Posts: 303
varchar or char

hi,
I just want to knew if what is the field to be use in order to save resources . The length of my input is <= 50 character. The varchar or char. Anyone have an input about my issue.

thanks,
Popskie
Reply With Quote
  #2 (permalink)  
Old 10-20-05, 12:49
jfulton jfulton is offline
Registered User
 
Join Date: Apr 2005
Location: Baltimore, MD
Posts: 297
Depends on what exactly you mean by resources and what kind of data is going into the columns. In general, VARCHAR is used for variable length strings. If your data is always going to be 50 characters long, use CHAR. If there will be large discrepancies in the length of strings that will be entered, consider using VARCHAR.

CHAR columns take up the designated amount of space for each record. VARCHAR columns only use the required amount of space + 1 extra byte. I believe that CHAR columns search faster, but VARCHARS take up less space (when used with variable length strings) and thus cut down on table size, which also keeps searches fast. For 50 characters, I don't think it would make much of a difference. If your entries are all going to be 50 characters, use CHAR, but for variable length strings, it is more logical to use VARCHAR.


Code:
CHAR(50) 
  -- will always hold 50 characters (pads shorter with whitespace.)
  -- will always use 50 bytes

VARCHAR(50) 
  -- will hold up to 50 characters (no padding shorter strings.)
  -- will use string length + 1 bytes
http://dev.mysql.com/doc/refman/5.0/en/char.html
Reply With Quote
  #3 (permalink)  
Old 10-20-05, 20:19
popskie popskie is offline
Registered User
 
Join Date: Oct 2004
Location: In cousin's house
Posts: 303
ok thanks for ur idea.
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