Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Mysql storing text - 500 chars max

Options
  • 04-07-2007 8:33pm
    #1
    Registered Users Posts: 1,086 ✭✭✭


    I am storing a string in my MySql database. I have a field with I want to hold max 500 characters.

    If I use the 'text' type will that column type be taking up an unnecessary amount of memory since the max string size of 'text' is 65535 chars. I'll only be storing 500 chars maximum.

    Am I better to use 2 varchar / tinytext fields which only hold 255 characters each?


Comments

  • Closed Accounts Posts: 382 ✭✭misterq


    you answered your own question.
    The size of the text field is a MAXIMUM of 65535 chars. That doesn't mean all columns of this type will be that size.
    The amount of space taken up by the column will be string length + 2 bytes.

    Eg: if you put in 500 chars, the data space taken up is 502 bytes.


  • Closed Accounts Posts: 7,563 ✭✭✭leeroybrown


    MySQL's handling of TEXT is pretty much the same as VARCHAR. In some other databases the TEXT type can have much more minimum overhead.


  • Registered Users Posts: 9,557 ✭✭✭DublinWriter


    Doesn't MySQL have a CLOB\MEMO (blob-like char) type field?


Advertisement