Re: citext question

From: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
To: Heine Ferreira <heine(dot)ferreira(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: citext question
Date: 2012-10-14 03:48:01
Message-ID: 507A35F1.8060809@ringerc.id.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 10/14/2012 05:48 AM, Heine Ferreira wrote:
> Hi
>
> I have played around a bit with the citext
> extention. It looks like it is a lot like the
> text data type - allmost like a memo
> field. Is there any way to restrict the
> length of citext fields, like char and
> varchar fields?

First, don't use "char(n)" or plain "char". Neither do what you (as a
sane and sensible person) probably expect them to do.

In PostgreSQL, "varchar(n)" is effectively the same as "text" with a
"length(col_name) <= n" CHECK constraint. There is no difference in how
they are stored, and there's no advantage to using "varchar" over "text".

It's similar with citext. While citext doesn't accept a typmod to
constrain its length, you can and should use CHECK constraints as
appropriate in your data definitions.

--
Craig Ringer

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Angelico 2012-10-14 04:02:06 Re: database corruption questions
Previous Message Craig Ringer 2012-10-14 03:28:02 Re: database corruption questions