This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Originally posted by Peter Primrose: if varchar(100) is just like varchar(20) than what is the diff? I mean, ok, the length is an issue but isn't there some kind of space issue?
Peter, Yes, it only uses 5 bytes to store the 5 byte name. It's more a matter of intent. I could declare all my fields to be varchar(255), but this would be misleading. varchar(30) better specifies my intent because I am declaring that there will not be more than 30 characters.
Also, it helps if you have a front end. If the database field is varchar(100), you have to be able to handle 100 character first names in your GUI.
As we know that there is a difference between char and varchar. VARCHAR doesn't use all given space.
Note the difference. Assume we have
FIRST_NAME varchar(20), and in other table we have FIRST_NAME varchar(100)
We insert same name in both, "peter". "peter" will occupy same space of 5 characters in both. But when it is about update name, then the DB should take care of it. Now the modified name could be of 98 characters for the second table. But for the first table it cant exceed more than 20.
So, why the hell you are saying the DB server that there might be 100 characters in future, although you know it is not going to happen ever. As it is the FIRST_NAME column not a COMMENT column. Why Bothering DB by saying something, which never gonna happen.