Home

citext

citext is a data type provided by PostgreSQL through the citext extension. It implements a case-insensitive text type intended for fields where comparisons should ignore letter case, such as usernames or email addresses.

The extension introduces the citext data type whose values are stored as text but are compared in

Usage is straightforward: install the extension with CREATE EXTENSION citext in a database, then declare columns

Limitations and considerations include that citext is PostgreSQL-specific and must be enabled per database. While it

a
case-insensitive
manner.
It
supports
standard
text
operators
and
can
be
used
with
B-tree
indexes
and
unique
constraints
to
enforce
case-insensitive
uniqueness.
This
makes
it
convenient
for
enforcing
consistent
constraints
and
performing
lookups
without
needing
to
transform
data
on
every
query.
as
CITEXT.
A
citext
column
can
be
indexed
with
a
conventional
B-tree
index,
and
constraints
such
as
PRIMARY
KEY
and
UNIQUE
behave
in
a
case-insensitive
way.
Queries
using
equality,
ordering,
or
pattern
matching
with
LIKE
or
ILIKE
on
citext
values
follow
the
type’s
case-insensitive
semantics,
which
can
simplify
logic
for
user-facing
identifiers.
simplifies
case-insensitive
comparisons,
it
may
interact
with
locale
or
collation
settings
in
ways
that
differ
from
plain
text
and
can
have
different
performance
characteristics.
An
alternative
approach
is
to
store
text
in
a
regular
text
column
and
create
functional
indexes
on
lower(column)
or
use
other
normalization
strategies
for
case-insensitive
lookups.