Search code examples
character-encodingpsqlpostgresql-9.3

PostgreSQL installation issue Character Type


I installed PostgreSQL 9.2 with default database postgres. It shows Collation and Character Type as en_GB.UTF-8.

Is there any difference between en_GB and en_US. Can I change to en_US without uninstalling.


Solution

  • First option is while creating a new database you may provide the Collation and Ctype like

    postgres=# CREATE DATABASE test  WITH LC_COLLATE='en_US'  Encoding='LATIN1' lc_ctype='en_US' TEMPLATE=template0;;
    CREATE DATABASE
    
    
    postgres=# \l
                                      List of databases
       Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
    -----------+----------+----------+-------------+-------------+-----------------------
     postgres  | postgres | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 | 
     template0 | postgres | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
     template1 | postgres | UTF8     | en_GB.UTF-8 | en_GB.UTF-8 | =c/postgres          +
               |          |          |             |             | postgres=CTc/postgres
     test      | postgres | LATIN1   | en_US       | en_US       | 
    (4 rows)
    

    Second option is to do the fresh initdb and provide the -E encoding and --locale=locale. Sets the default locale for the database cluster. If this option is not specified, the locale is inherited from the environment that initdb runs in

    See more details about initdb with --locale at postgres initdb