Re: Collation problem?

From: Bjørn T Johansen <btj(at)havleik(dot)no>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Collation problem?
Date: 2015-04-26 09:09:07
Message-ID: 20150426110907.471c5906@pennywise2.havleik.net
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, 26 Apr 2015 10:59:10 +0200
Bjørn T Johansen <btj(at)havleik(dot)no> wrote:

> On Sun, 26 Apr 2015 10:31:37 +0200
> "Gunnar \"Nick\" Bluth" <gunnar(dot)bluth(at)pro-open(dot)de> wrote:
>
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Am 26.04.2015 um 10:02 schrieb Bjørn T Johansen:
> > > My databases looks like this...:
> > >
> > >
> > > List of databases Name | Owner | Encoding | Collate
> > > | Ctype | Access privileges
> > > --------------+--------------+----------+-------------+-------------+-
> > - ----------------------
> > >
> > >
> > dbname | owner | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
> > > .......
> > >
> > >
> > > And my problem is that I am using Norwegian in some tables and when
> > > using order by the sort order is not correct for the Norwegian
> > > letters.. So my guestion is if it is possible to get the correct
> > > sort order without recreating all my databases or initialize
> > > PGSQL?
> > >
> > Sure (i.e., if you're on a half recent version):
> >
> > ALTER TABLE <yourtable> ALTER COLUMN <yourcolumn> COLLATE <collation>
> >
> >
> > http://www.postgresql.org/docs/9.4/static/sql-altertable.html
> >
>
> Yes, I am using 9.4.x so I will check this out... Thx... :)
>
> BTJ
>
>

Ok, tried to run:

alter table medlem alter column fornavn varchar(50) collate nb_NO.utf8

But I just get:

[Error Code: 0, SQL State: 42601] ERROR: syntax error at or near "varchar"
(tried without the varchar also..)

Also tried running:

select fornavn from medlem order by fornavn collate nb_NO

Then I get:

ERROR: collation "nb_no" for encoding "UTF8" does not exist

Do I need to add some collation to the database or?

BTJ

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Oliver Elphick 2015-04-26 09:48:37 Re: Collation problem?
Previous Message Bjørn T Johansen 2015-04-26 08:59:10 Re: Collation problem?