PG字符:字符集支持

1.创建数据库的时候会指定encoding编码:

CREATE DATABASE test WITH ENCODING = 'GBK'---此处的encoding并不支持GBK,可以使用EUC_CN替代GBK;

********** Error **********
错误: GBK 是一个无效编码名字
SQL state: 42704

create database test with encoding = 'UTF8';---支持UTF8

2.创建一个数据库连接之后可以修改client_encoding:

set client_encoding='GBK'; -此处支持GBK,此时该设置仅对该连接有效
show client_encoding;

-----------------------

GBK

3.pg官网对字符集支持的阐述:

   http://www.postgresql.org/docs/9.3/interactive/multibyte.html#MULTIBYTE-CHARSET-SUPPORTED

NameDescriptionLanguageServer?Bytes/CharAliases
BIG5Big FiveTraditional ChineseNo1-2WIN950, Windows950
EUC_CNExtended UNIX Code-CNSimplified ChineseYes1-3 
EUC_JPExtended UNIX Code-JPJapaneseYes1-3 
EUC_JIS_2004Extended UNIX Code-JP, JIS X 0213JapaneseYes1-3 
EUC_KRExtended UNIX Code-KRKoreanYes1-3 
EUC_TWExtended UNIX Code-TWTraditional Chinese, TaiwaneseYes1-3 
GB18030National StandardChineseNo1-2 
GBKExtended National StandardSimplified ChineseNo1-2WIN936, Windows936
SQL_ASCIIunspecified (see text)any Yes1 
UHCUnified Hangul CodeKoreanNo1-2WIN949, Windows949
UTF8Unicode, 8-bitall Yes1-4Unicode

4.在新建数据库的时候,指定的Encoding会影响LC_CTYPE,使用的template也会影响编码:

http://www.postgresql.org/docs/9.3/interactive/sql-createdatabase.html

The character set encoding specified for the new database must be compatible with the chosen locale settings (LC_COLLATE and LC_CTYPE). If the locale is C (or equivalently POSIX), then all encodings are allowed, but for other locale settings there is only one encoding that will work properly. (On Windows, however, UTF-8 encoding can be used with any locale.) CREATE DATABASE will allow superusers to specify SQL_ASCII encoding regardless of the locale settings, but this choice is deprecated and may result in misbehavior of character-string functions if data that is not encoding-compatible with the locale is stored in the database.

The encoding and locale settings must match those of the template database, except when template0 is used as template. This is because other databases might contain data that does not match the specified encoding, or might contain indexes whose sort ordering is affected by LC_COLLATE andLC_CTYPE. Copying such data would result in a database that is corrupt according to the new settings. template0, however, is known to not contain any data or indexes that would be affected.



转载于:https://my.oschina.net/liuyuanyuangogo/blog/307326

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值