EasyBB
EasyBB

Reputation: 6574

SQL varchar character limit

I have read different explanations of varchar and so far I've gotten this:

CHAR( )      fixed from 0 to 255 characters long 
VARCHAR( )   variable from 0 to 255 characters long 
TINYTEXT     maximum length of 255 characters 
TEXT         maximum length of 65535 characters 
BLOB         maximum length of 65535 characters 
MEDIUMTEXT   maximum length of 16777215 characters 
MEDIUMBLOB   maximum length of 16777215 characters 
LONGTEXT     maximum length of 4294967295 characters 
LONGBLOB     maximum length of 4294967295 characters

and then this

So really what is the character max on varchar? Reason I am wondering is I am starting a simple little CMS and I don't want my SQL DB to overloaded with weight and as you can see for example

nvarchar(max)[length] * 2 + 2 
nvarchar being 100,000 * 2 + 2 = 200,002 bytes (what is + 2 is it literal?)

Also I've read that varchar(8,000) is better than varchar(max) so what would you suggest the type that I use for a variably changing character length, especially for content.

Upvotes: 6

Views: 44947

Answers (1)

mukunda
mukunda

Reputation: 2995

http://dev.mysql.com/doc/refman/5.0/en/char.html

  The length can be specified as a value from 0 to 255 before MySQL 5.0.3, 
  and 0 to 65,535 in 5.0.3 and later versions.

I don't think your second paste is talking about MySQL.

Upvotes: 8

Related Questions