Okay! As you can see, the database didn't let you enter a value which was longer than the maximum. Quite understandable, isn't it? The type
varchar(x) lets you provide any value which is shorter than or equal x.
There is also another type called
char. The difference is that it stores fixed-size information. For instance,
varchar(10) lets you add any value of up to 10 characters, whereas
char(10) expects you to enter exactly 10 characters each time.
When do we use it? Consider the vehicle identification number (VIN). Its length is fixed - it is always 17 characters long. That makes a perfect candidate for
char(17) data type.