varchar(n) VS text

Поиск
Список
Период
Сортировка
От Pierre Thibaudeau
Тема varchar(n) VS text
Дата
Msg-id 74b035bb0706252059s55fb0c5i49417e3d034e0091@mail.gmail.com
обсуждение исходный текст
Ответы Re: varchar(n) VS text  (Ben <bench@silentmedia.com>)
Re: varchar(n) VS text  (Tom Lane <tgl@sss.pgh.pa.us>)
Список 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 по дате отправления:

Предыдущее
От: "Mikko Partio"
Дата:
Сообщение: Re: data partitions across different nodes
Следующее
От: Ben
Дата:
Сообщение: Re: varchar(n) VS text