varchar(n) VS text
От | Pierre Thibaudeau |
---|---|
Тема | varchar(n) VS text |
Дата | |
Msg-id | 74b035bb0706252059s55fb0c5i49417e3d034e0091@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: varchar(n) VS text
Re: varchar(n) VS text |
Список | pgsql-general |
Having read http://www.postgresql.org/docs/8.2/interactive/datatype-character.html I am puzzling over this issue: 1) Is there ever ANY reason to prefer "varchar(n)" to "text" as a column type? 2) For instance, if I know that a character-type column will never contain more than 300 characters, would I be better to define it as "varchar(300)" or as "text"? 3) What if, in practice that same column usually contains strings of no more than 10 characters (although I can't guarantee that it wouldn't explode up to 300 in the one-in-a-million case)? 4) On the other hand, what if a column systematically contains strings of 5 or fewer characters. Is it better to define it as "varchar(5)" or as "text"? From my reading of the dataype documentation, the ONLY reason I can think of for using "varchar(n)" would be in order to add an extra data-type constraint to the column.
В списке pgsql-general по дате отправления: