0

As I understand if you declare a column as varchar(15) or varchar(200), it makes no difference in memory size. If you store a 4-character string it should only use around 4 bytes. This is the same in Oracle for varchar2. But, for Oracle, their performance are different as the bigger size you set, the more overhead will be used.

Is it the same in MySQL (or any other database)?

raina77ow
  • 103,633
  • 15
  • 192
  • 229
user1619397
  • 680
  • 2
  • 11
  • 23
  • In mysql it uses length+1 bytes or if you have defined varchar bigger than 255 then length+2 bytes. If the field is utf8 then the size in bytes may be upto 3 times the declared size – Imre L Sep 07 '12 at 16:43
  • thanks for the reply. I understood what you said. how about the overhead? would that be the same or major different – user1619397 Sep 10 '12 at 08:45
  • I'd say that is about same. Worrying about this is "micro optimisation" – Imre L Sep 10 '12 at 08:48

1 Answers1

0
  • VARCHAR:

    1. Stores strings of variable length.
    2. The length parameter specifies the maximum length of the strings
    3. It stores up to 2000 bytes of characters
    4. It will occupy space for NULL values
    5. The total length for strings is defined when database was created.
  • VARCHAR2:

    1. Stores strings of variable length.
    2. The length parameter specifies the maximum length of the strings
    3. It stores up to 4000 bytes of characters
    4. It will not occupy space for NULL values
    5. The total length of strings is defined when strings are given
hjpotter92
  • 78,589
  • 36
  • 144
  • 183