Historically, I've always used char(len) rather than varchar(len) in cases where I *know* the values will be a certain length exactly, such as SHA-1 hashed passwords. To me it makes sense. My argument is not strengthened by the SQL standard, since it will happily take a character field shorter than 32 characters and store it in a char(32) field after padding it.
According to the docs on postgresql, there is no speed difference between char(len) and varchar(len). I dunno if this is true for all db platforms and it may give me trouble with index speeds if not. I plan on making this application run on many db platforms, and liked hibernate because it can help me in that endever.
I guess I will switch to using varchar(len) and tweaking the exported SQL by hand where necessary.
Thank your for your consideration.
|