8

I have a table with about 2 million records in it. I have a field called message which is setup as varchar(160) and I need something bigger that varchar(255) because I need to be able to store about 500 characters in it, what is the next best datatype to use without increasing the size of the db drastically?

thanks

user1005319
  • 231
  • 1
  • 4
  • 8

3 Answers3

11

Starting with MySQL 5.0.3, you can simply use VARCHAR(500).

M represents the maximum column length in characters. In MySQL 5.0, the range of M is 0 to 255 before MySQL 5.0.3, and 0 to 65,535 in MySQL 5.0.3 and later.

Sergey Kalinichenko
  • 714,442
  • 84
  • 1,110
  • 1,523
3

If you're on 5.0.3 or later a varchar can be 65535 characters.

11.4.1. The CHAR and VARCHAR Types

MySQL: Large VARCHAR vs. TEXT

Community
  • 1
  • 1
idstam
  • 2,848
  • 1
  • 21
  • 30
0

You could use TEXT then Run PROCEDURE ANALYSE

that suggests optimal data types for each column that may help reduce table sizes.

Leo
  • 10,407
  • 3
  • 45
  • 62