簡體   English   中英

在PostgreSQL 9.1中更改編碼

[英]Change encoding in PostgreSQL 9.1

我有以下數據庫

sudo -u postgres psql -c "\list"

                             List of databases
   Name    |  Owner   | Encoding | Collate | Ctype |   Access privileges   
-----------+----------+----------+---------+-------+-----------------------
 postgres  | postgres | LATIN1   | en_US   | en_US | 
 template0 | postgres | LATIN1   | en_US   | en_US | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
 template1 | postgres | LATIN1   | en_US   | en_US | =c/postgres          +
           |          |          |         |       | postgres=CTc/postgres
(3 rows)

如何在數據庫template1template0中將編碼從LATIN1更改為UTF8?

由於此處似乎沒有任何實際數據,只需關閉並刪除集群(服務器和數據庫集)並重新創建它。 您使用的是哪種操作系統? 用於創建新集群的標准PostgreSQL命令是initdb,但在Debian / Ubuntu等pg_createcluster您通常使用pg_createcluster

另請參見如何更改postgres數據庫的字符編碼?

雖然您可以嘗試調整編碼,但不建議這樣做。 即使我在那個鏈接的問題中建議,如果你在這里有latin1字符的數據,你需要將它們重新編碼為utf-8。

只需使用:

更新pg_database set encoding = pg_char_to_encoding('LATIN1')其中datname ='seguros'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM