Re: Difference between varchar and text?

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: Difference between varchar and text?
Дата
Msg-id CAHyXU0w7FtXRhfuswJDCrV1vX9K9yBgX3aG0Hk0C9x4LRWLXgQ@mail.gmail.com
обсуждение исходный текст
Ответ на Difference between varchar and text?  (Moshe Jacobson <moshe@neadwerx.com>)
Список pgsql-general
On Mon, Nov 5, 2012 at 2:46 PM, Moshe Jacobson <moshe@neadwerx.com> wrote:
> Is there any practical difference between defining a column as a varchar(n)
> vs. a varchar vs. a text field?

not much.  varchar(n) only forces the length to be <= n.  I dislike
inventing an 'n' when one is not known, but a lot of people do it.

> I've always been under the impression that if I am wanting to index a
> varchar column, it is better to set a maximum length. Is this correct?
> But more importantly, what's the practical difference between varchar with
> no limit and text?

That is pretty much true.  Index entries for a column in a btree are
constrained to a be of a size of slightly less than page size. But
this is true if you set the length or not.

merlin


В списке pgsql-general по дате отправления:

Предыдущее
От: Moshe Jacobson
Дата:
Сообщение: Difference between varchar and text?
Следующее
От: John R Pierce
Дата:
Сообщение: Re: Difference between varchar and text?