How to change location in PostgreSQL

4

My database has locale en_US.UTF-8 , I need to change it to pt_BR.UTF-8 for query sorting.

How can I do this with only phpPgAdmin ?

    
asked by anonymous 30.06.2015 / 20:04

1 answer

4

To change you will have to:

  • Make a logical backup of your current base, maybe you have this option in phpPgAdmin, but I do not know, via the command line it would look something like:

    $ pg_dump -d nome_da_base -f nome_da_base.sql
    
  • Delete your current database:

    DROP DATABASE nome_da_base;
    
  • Recreate using using template0 and locale correct:

    CREATE DATABASE nome_da_base
        TEMPLATE=template0
        LC_CTYPE="pt_BR.UTF-8"
        LC_COLLATE="pt_BR.UTF-8";
    
  • Restore:

    $ psql -d nome_da_base -f nome_da_base.sql
    
  • If your database is very large, this process may be a bit slow, in this case it would be better to use a binary backup (recommend -Fc , or -Fd to use parallelism) and restore with pg_restore using parallelism

        
    01.07.2015 / 18:46