Re: CHAR(N) storage requirement

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: David Garamond <lists(at)zara(dot)6(dot)isreserved(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: CHAR(N) storage requirement
Date: 2004-01-11 16:02:00
Message-ID: 200401111702.00538.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

David Garamond wrote:
> Is it the 4+N (aka. same as VARCHAR(n)) or is it N? Sorry, it was
> 100% not clear for me after reading the docs, though the docs imply
> the first: "The storage requirement for data of these types is 4
> bytes plus the actual string, and in case of character plus the
> padding."

Storing varchar(n) takes 4 bytes plus as many bytes as are required to
store the actual string. This may be more or less then "n".

Storing char(n) takes 4 bytes plus as many bytes are are required to
store the actual string, plus n - length(value) bytes for padding
spaces. This is at least "n" bytes.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-01-11 16:42:51 Re: CHAR(N) storage requirement
Previous Message David Garamond 2004-01-11 15:56:16 Drawbacks of using BYTEA for PK?