【发布时间】:2014-03-16 10:54:52
【问题描述】:
我查看了类似的问题,但仍然没有找到合适的解决方案。
在我的 Ubuntu 操作系统上,我通过以下方式创建了一些数据库:
createdb PADB -W
并创建了一个表。
create table teacher(
id_teacher integer PRIMARY KEY,
name varchar(120),
experience integer
);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "teacher_pkey" for table "teacher"
我想添加一些包含西里尔字母的数据,但是我收到了这个错误:
PADB=# insert into teacher (name, experience) values ("Пупкин Василий Иванович", 15);
ERROR: invalid byte sequence for encoding "UTF8": 0xd0d0
这是我的 lc 设置:
PADB=# select name, setting from pg_settings where name like 'lc_%';
name | setting
-------------+-------------
lc_collate | ru_RU.UTF-8
lc_ctype | ru_RU.UTF-8
lc_messages | ru_RU.UTF-8
lc_monetary | ru_RU.UTF-8
lc_numeric | ru_RU.UTF-8
lc_time | ru_RU.UTF-8
(6 rows)
怎么了?
PostgreSQL 9.1.11
【问题讨论】:
-
你的 mysql 客户端可能没有以 utf8 格式发送数据
-
您使用什么客户端应用程序连接到 PostgreSQL?
-
顺便说一句:
id_teacher integer PRIMARY KEY,:id_teacher 不能为 NULL,因此您的插入将失败,因为它没有为 id_teacher 提供值。 (你是说SERIAL吗?) -
另外,请在您运行
psql的终端中显示locale命令的输出。完成后在此处编辑问题和评论。 -
如果你的意思是连载,你应该说连载。只是为了不让我们猜测。
标签: linux database postgresql utf-8 postgresql-9.1