2013-10-17 52 views
6

我如何更改整理,CTYPE來 - 從en_US.UTF-8更改數據庫整理,CTYPE在PostgreSQL

       List of databases 
    Name | Owner | Encoding | Collation | Ctype | Access privileges 
-----------+----------+----------+-------------+-------------+----------------------- 
postgres | postgres | UTF8  | en_US.UTF-8 | en_US.UTF-8 | 
template0 | postgres | UTF8  | en_US.UTF-8 | en_US.UTF-8 | =c/postgres 
                  : postgres=CTc/postgres 
template1 | postgres | UTF8  | en_US.UTF-8 | en_US.UTF-8 | =c/postgres 
                  : postgres=CTc/postgres 

我目前postgresversion en_IN是8.4 香港專業教育學院使用

sudo apt-get install postgresql-8.4 postgresql-contrib-8.4 

IM在做這個安裝了它我的ubuntu亞馬遜服務器ec2

+0

您不能更改數據庫排序規則。你需要重新創建(轉儲/重新加載)數據庫與新的排序 –

+0

當我嘗試創建一個數據庫與en_IN無法做到:( –

+0

當前即時通訊使用我自己的本地系統作爲服務器..並已在運行。現在我得到了一個新的Ubuntu的12.04亞馬遜EC2實例從亞馬遜和即時通訊試圖移動我的服務器。所以你應該怎麼做我應該這樣做?PLZ –

回答

6

我的推薦:

  1. 採取pg_dumpall

  2. 重新初始化數據庫集羣,確保區域設置信息是正確的

  3. 恢復轉儲。

我發現,有時可能的是,一個可能必須創建與模板template0中(-T template0中從bash或在psql WITH TEMPLATE template0)一個分貝到使用非INIT-分貝的區域設置。

+0

我不明白第2點 –

+0

你一定要閱讀文檔和看看你的系統區域設置是如何設置的,但你通常可以:'initdb --lc-collat​​e en_IN --lc-ctype en_IN -D ....' –

3

不需要重新創建整個數據庫集羣。但是,您需要重新創建數據庫。

使用這些選項運行CREATEDB(man createdb):

-E encoding, --encoding=encoding 
     Specifies the character encoding scheme to be used in this 
     database. The character sets supported by the PostgreSQL server 
     are described in Section 22.3.1, 「Supported Character Sets」, in 
     the documentation. 

    -l locale, --locale=locale 
     Specifies the locale to be used in this database. This is 
     equivalent to specifying both --lc-collate and --lc-ctype. 

    --lc-collate=locale 
     Specifies the LC_COLLATE setting to be used in this database. 

    --lc-ctype=locale 
     Specifies the LC_CTYPE setting to be used in this database. 

看來你真的不能更改現有數據庫的歸類:

=> ALTER DATABASE dbname SET "Collate" To Russian; 
ERROR: unrecognized configuration parameter "Collate" 

注意,您可以對一組整理表或列,請參閱PostgreSQL中排序規則的tutorial