Situation:
varchar(20)
seems to truncate silently in Teradata and not to expand or complain when encountering strings larger than 20 characters long... This is a bit of a surprise as I expected either automatic expansion of the column to fit larger strings, say 30 characters, OR for an error to be thrown if a larger string were encountered. Silent truncation seems to get me the worst of all worlds...
Complication:
For my application (prototype analytics design) I don't know in advance how large will be the data I will be ingesting over the course of a few weeks. That seems to rule out using varchar(N), except for max
Questions:
So now I have a few choices, and am looking for some guidance:
Q1. User error? Am I misunderstanding a key concept about varchar(N)
?
If this is in fact how Teradata handles varchar
fields, then
Q2. why would anyone specify anything less than varchar(max)
especially when it is not clear in advance how many characters might need to be stored in the field.
Q3. Is there a different data type that permits flexible sizing of the string -- i.e. a true variable length character string?
If I recall, other SQL dialects implement varchar(n)
as a recommended initial size for the string but allow it to expand as needed to fit the maximum length of the data strings thrown in. Is there a similar data type in Teradata?
(Note: since I'm prototyping the tables, I am less concerned about performance efficiency at this point; more concerned about quick but safe designs that allow the prototype to progress.)