Re: PG SQL and LIKE clause - Mailing list pgsql-general

From Tom Lane
Subject Re: PG SQL and LIKE clause
Date
Msg-id 20804.1568384675@sss.pgh.pa.us
Whole thread Raw
In response to PG SQL and LIKE clause  (Matthias Apitz <guru@unixarea.de>)
List pgsql-general
Matthias Apitz <guru@unixarea.de> writes:
> We got to know that in CHAR columns with trailing blanks a 

> SELECT ... FROM ... WHERE name LIKE 'Ali'

> does not match in 'name' having 'Ali '.

> I glanced through our code with grep pipelines and found some hundred
> places which would be affected by this problem. I'm not interested in a
> religious discussion if or if not this behaviour of PG is correcter or
> better than in Sybase. It's just different to Sybase.

> Any hints to address this problem?

Don't use char(n) for anything more complicated than cases like
it-must-be-a-2-character-state-abbreviation.  You can use varchar(n)
if you must have an upper limit on the field length.  Or text.

            regards, tom lane



pgsql-general by date:

Previous
From: Ray O'Donnell
Date:
Subject: Re: backing up the data from a single table?
Next
From: Ron
Date:
Subject: Re: backing up the data from a single table?