gpt4 book ai didi

sql - Postgres 将 LATIN1 编码的文件复制到 UTF 编码的表中

转载 作者:行者123 更新时间:2023-11-29 11:29:06 25 4
gpt4 key购买 nike

我在批量插入时遇到问题。我正在尝试从编码为 LATIN1 的文件批量插入编码为 UTF8 的数据库中的表。

invalid byte sequence for encoding "UTF8": 0xc33f 

当我执行 SET CLIENT_ENCODING='LATIN1' 并从控制台执行 COPY 后,它工作正常。但是 JDBC 告诉我他不能做 SET CLIENT_ENCODING。

拜托,你能建议我如何解决问题的解决方案吗?谢谢!

最佳答案

尝试设置allowEncodingChanges连接参数设置为 true 以允许(暂时)将客户端编码更改为 LATIN1。根据Table 22-2 PostgreSQL 应处理 LATIN1(客户端)和 UTF8(服务器)之间的自动字符集转换。

The client_encoding setting is set bythe driver and should not be altered.If the driver detects a change it willabort the connection. There is onelegitimate exception to this behaviorthough, using the COPY command on afile residing on the server'sfilesystem. The only means ofspecifying the encoding of this fileis by altering the client_encodingsetting.

Enable this only if you needto override the client encoding whendoing a copy.

关于sql - Postgres 将 LATIN1 编码的文件复制到 UTF 编码的表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6277029/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com