The VARCHAR
by definition has variable size, you can put the size you want there, at least within the ANSI standard. This 255 is just information of how it should be shown in a selection, it does not mean that it will occupy this disk space. There is no waste.
You can define whatever you want, it doesn’t change anything significantly. 255 is a number that holds most of the information. In the past this was the maximum size of a VARCHAR
, then I could show everything.
Some databases use this as Constraint and do not let pass of this value, ie it is only a maximum possible.
Specifically about email if you want to have enough space for any email that can be up to 254 in size according to RFC. You can’t model the bank to handle 99.999% inserts, it has to be suitable for 100% of registrations.
It is the opposite of what in theory should happen to the CHAR
that has fixed size. In thesis if a CHAR
is 255 in size that is what it will occupy even if the value only has one character. I say in theory, because it has Sgdbs that can store up to one CHAR
variable size, although it preserves the semantics of CHAR
. If the row has some column of variable size has no reason to keep one of fixed size, there is no gain in it.
This can be confirmed in OS response from one of the leading database experts. To Wikipedia talks about it. And you still have the documentation of the guys in the databases:
You didn’t want reference?
– Maniero