Assuming the following fields (for example): Nome
, Rua
, Cidade
, UF
.
The Nome
would be the name of the client. There are people with 2 short names or people with 5 or more names, so it is possible to have a "João Silva" or a "Maria Clara Ramos Santos da Silva", that is, people with 10 characters and people with 27 characters more).
The Rua
would be the street name of the client: Same as in the previous example.
The Cidade
would be the client city: The same as the previous example.
The UF
would be the client state: Since I would only like the acronym, it will not have been with 5 or more letters, only 2.
Is it worth putting VARCHAR(255)
to all or is it better to choose the best size for each field? When I say "best," I'm referring to not spend unnecessary space, type having a 255-character field and only storing values with only 2 letters (UF). I read in other answers that VARCHAR()
is a dynamic format, the value passed between parentheses is only the maximum value that field will support, is this true? If it is, then it is worth putting VARCHAR(255)
for all fields, since the value will be dynamic with a maximum of 255, so the maximum is 255, however it will only have 2 letters so it will only store the space required for 2 letters and not 255.
"Choosing best size" = Nome VARCHAR(100)
, Rua VARCHAR(120)
, Cidade VARCHAR(100)
, UF VARCHAR(2)
.
I had this doubt because I'm about to create a database for a MySQL system, but my question is about the database in general, not just MySQL.