From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Matthias Apitz <guru(at)unixarea(dot)de> |
Cc: | pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: PG SQL and LIKE clause |
Date: | 2019-09-13 14:24:35 |
Message-ID: | 20804.1568384675@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Matthias Apitz <guru(at)unixarea(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Ron | 2019-09-13 14:27:58 | Re: backing up the data from a single table? |
Previous Message | Ray O'Donnell | 2019-09-13 14:17:03 | Re: backing up the data from a single table? |