6

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
  • 181
  • 1
  • 3
  • 8

3 Answers3

8

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
  • 697,062
  • 78
  • 1,055
  • 1,465
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,765
  • 1
  • 20
  • 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
  • 9,231
  • 2
  • 41
  • 54