Can anyone tell me what is better to use for items such as names and addresses? I suspect VARCHAR(max anticipated length) but why? Is it because Text will pad?
What do you mean by "Text will pad"? I can think of two distinct possibilities,
only one of which is true.
One difference between VARCHAR and TEXT is that trailing whitespace truncation occurs for VARCHAR, but not for TEXT. This may be significant for your applications.
These queries issue the distinction:
DROP TABLE IF EXISTS t; CREATE TABLE t (ch VARCHAR(255), tx TINYTEXT); INSERT INTO t (ch, tx) VALUES('x ','x '); SELECT LENGTH(ch), LENGTH(tx) FROM t;
The ch and tx columns both have a maximum length of 255 bytes, so they are equivalent in terms of what kinds of values you can store into them. But some values will be treated differently. The result of the SELECT is:
+------------+------------+ | LENGTH(ch) | LENGTH(tx) | +------------+------------+ | 1 | 3 | +------------+------------+
-- Paul DuBois, Senior Technical Writer Madison, Wisconsin, USA MySQL AB, www.mysql.com
Are you MySQL certified? http://www.mysql.com/certification/
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]