So why do we always have to specify
VARCHAR(length) rather than just
VARCHAR? It's dynamic anyway.
UPD: I am puzzled particularly because it's mandatory (e.g. in MySQL).
To begin with, it doesn't needed it in most databases. Take a look at SQL Server, where it's optional.
Regardless, it defines a maximum size for that content from the area. Not necessarily a bad factor by itself, also it conveys meaning (for instance - telephone numbers, in which you don't want worldwide amounts within the area).
The "length" from the VARCHAR isn't the entire contents, it's the maximum entire contents.
The max period of a VARCHAR isn't dynamic, it's fixed and for that reason needs to be specified.
If you won't want to define a maximum size for this then use VARCHAR(MAX).
The greater the database is aware of the information it's storing, the greater optimisations celebrate when searching/adding/upgrading data with demands.
You can observe it as being a constraint in your data. It guarantees you don't store data that violates your constraint. It's conceptionally much like e.g. a cheque constraint on the integer column that make sure that only positive values are joined.
Varchar fields could be associated with a size-up towards the limit. The limit is different from kinds of databases, an Oracle 9i Database includes a limit of 4000 bytes, a MySQL Database includes a limit of 65,535 bytes (for the whole row) and Microsoft SQL Server 2005 8000 bytes (unless of course varchar(max) can be used, which includes a maximum storage capacity of 2,147,483,648 bytes).
The reply is you don't have to, it's optional.
It's there if you wish to make sure that strings don't exceed a particular length.