Re: name vs varchar vs text? - Mailing list pgsql-general

From Ian Lance Taylor
Subject Re: name vs varchar vs text?
Date
Msg-id siae6yn5p5.fsf@daffy.airs.com
Whole thread Raw
In response to name vs varchar vs text?  ("mike" <mike@quadrent.net>)
List pgsql-general
"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

pgsql-general by date:

Previous
From: Lamar Owen
Date:
Subject: Re: python-postgres RPM
Next
From: Soma Interesting
Date:
Subject: time to integer