Обсуждение: name vs varchar vs text?

Поиск
Список
Период
Сортировка

name vs varchar vs text?

От
"mike"
Дата:
reading through the curent development docs, I've run accross a data type called "name", and it looks very similar to varchar or text, and I'm wondering if there is any atvantage to useing this data type over varchar or even text?

Re: name vs varchar vs text?

От
Ian Lance Taylor
Дата:
"mike" <mike@quadrent.net> writes:

> reading through the curent development docs, I've run accross a data type called "name", and it looks very similar to
varcharor text, and I'm wondering if there is any atvantage to useing this data type over varchar or even text? 

The NAME type is used to hold table and column names.  It is a fixed
length char field of length NAMEDATALEN in postgres_ext.h (default
32).

If you happen to want a field which has a fixed size of 32 characters,
you can use NAME.  Or you can use CHAR(32).  NAME is actually slightly
different from CHAR(32), in that no length is stored with a NAME
field.  That probably makes NAME a bit more efficient.  I don't know
why a length is stored with a fixed length CHAR field, but it is.

Ian