I'm not a developer, however i have spent years testing and controlling software projects. Bugs triggered by leading and trailing whitened space in strings are just like war wounds which will never completely heal.

And So I request, with what the situation is leading and trailing whitened spaces advantageous?

Speed. While using CHAR datatype (which preserves trailing spaces) will frequently be faster than VARCHARS. With that said, after i stumbled upon a database that utilizes the CHAR type, Time passes searching for its designer by having an axe - the rate difference rarely makes up for that impossibility of while using CHAR type.

Markdown uses two spaces in the finish of the line like a marker for stating that that newline ought to be converted into a <br>. :-P

Seriously, beyond such corner cases, I do not really visit a indicate keeping leading/trailing spaces around. YMMV. :-)

I believe a much better real question is why is not it standard practice to enforce this constraint or create custom data types in the database level.

Most likely since it is more development build up front, and it is a simple factor to skip.

Good things about NOT trimming strings of leading and trailing whitened spaces in database programs


all data ought to be formatted consistently within the database. jetski from every query needing to code for those possible exceptions.

When storing in fixed length string data types like CHAR, all information is saved consistently (fixed length), thus this isn't the best, and meets my above rule. To grow on Neil Butterworth answer that CHAR may also be faster. it is dependent around the length, CHAR(5) may have a benefit, since it is simpler for that DB predict rows per page, and discover the row within the page. However CHAR(2000) is terrible in comparison to varchar(2000), you will have many less rows per page.