VARCHAR and TEXT

From: "Paolo Sinigaglia" <sini(at)informativesystem(dot)it>
To: <pgsql-general(at)postgresql(dot)org>
Subject: VARCHAR and TEXT
Date: 2001-03-29 14:53:46
Message-ID: 03c101c0b860$0ead8d40$0f00140a@paolo.informativesystem.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi everybody,
I have a little question about string types in PostgreSQL: it seems I don't
understood well how string data are stored in the database, from a recent
post by Tom Lane I feel encouraged to think that VARCHAR and TEXT are
treated the same way by PG, i.e. they occupy ony the space needed by their
actual length, bt I'm not so sure of it.

I ask this because I'm trying using PG as database server in a project
developed in delphi under ms-win and it seems to me that varchar and text
fields are not treated the same way by odbc interface and/or bde (borland
database engine, the database interface layer used by delphi programs). When
I connect to a table the fields of type VARCHAR are seen as strings while
the fields of type TEXT are seen as blobs, and this is a little upsetting,
because some useful functions are not implemented for blob fields.

I have several tables with fields that could contain quite lengthy strings,
but usually don't. So I don't want to define theese fields as VARCHAR(400)
if this means a disk occupation of 400 bye or so for each row (I have some
500000 rows in a table and the average length of the field in question is
about 30, but the max length is near 400).

Can someone clarify this point?

Thanks in advance

___________________PS

Responses

Browse pgsql-general by date

  From Date Subject
Next Message will trillich 2001-03-29 15:33:35 Re: Fwd: Re: timestamp/function question
Previous Message Pluto 2001-03-29 13:54:52 Data access permission?