"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
agree w/ Nogdog's cross post with just this point:
use varchar almost exclusively, if it's free text. if it's an enumerated value (where you guarantee the length or something) you should be using enum. CHAR field always ends up w/ wasted memory.
Hey, Chazzy, I was under the impression that CHAR was more efficient than VARCHAR if the field in question always or nearly always contained the max number of allowed characters (or very close to the max with larger fields). Thus, for something like a password field, CHAR might be more appropriate if you are storing the MD5 hash, for example, which will always be the same length. Is this correct, or is it a misunderstanding on my part?
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
If you can guarantee that the value will always be 32 characters (for example) then you would use CHAR types. However, for any field that can have any # of characters up to N (say 255, for example) then you would use VARCHAR, so yeah your understanding's correct. most people will simply always use varchar, as it'll be easier to convert if need be.
Bookmarks