character-encoding - PostgreSQL 安装问题 Character Type
问题描述
我使用默认数据库 postgres 安装了 PostgreSQL 9.2。它将排序规则和字符类型显示为 en_GB.UTF-8。
en_GB 和 en_US 之间有什么区别吗?我可以在不卸载的情况下更改为 en_US。
解决方案
第一个选项是在创建新数据库时,您可以提供 Collation 和 Ctype 之类的
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)
第二种选择是执行新的 initdb 并提供 -E 编码和 --locale=locale。设置数据库集群的默认语言环境。如果未指定此选项,则从 initdb 运行的环境继承语言环境
在postgres initdb中使用 --locale 查看有关 initdb 的更多详细信息
披露:我为EnterpriseDB (EDB)工作
推荐阅读
- vba - Excel在工作簿中的最后一张工作表之后添加带有代码的工作表
- sql - 按 SQL 表中的出现次数过滤
- c++ - C++:为什么 unordered_set::find 比 find 快?
- c++ - Visual Studio 发布模式 exe 文件是否独立?
- php - .htaccess 将子目录重定向到它的 index.php 文件
- python - 缺少必需的位置参数:Python:self
- c# - webclient 不下载完整的文件
- arrays - 使用 for 循环加宽斐波那契花
- can-bus - CAN 套接字 - 句柄不是 ACK
- mysql - laravel 只获取重复数据的第一行