gpt4 book ai didi

postgresql - 当 .sql 文件是 ANSI 时,pg_dump 是否保留所有 Unicode 字符?

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

我用

pg_dump.exe -U postgres -f "file-name.sql" database-name

在 PostgreSQL 8.4 和 9.5、Windows 主机上备份 UTF-8 编码的数据库。有些可能在字符列中存储了外来字符,例如中文、泰语等。

生成的 .sql 文件在 Notepad++ 中打开时显示 ANSI 编码(默认情况下,我不会将 ANSI 应用于打开的文件)。我如何知道 Unicode 字符是否始终保留在转储文件中?我应该改用存档(对象)备份文件吗?

最佳答案

Quote from the manual

By default, the dump is created in the database encoding.

如果不使用扩展字符,ANSI 编码和 UTF-8 编码的文本文件没有区别。也许您的转储没有特殊字符,因此编辑器不会将其识别为 UTF-8。

如果您想要以特定编码进行 SQL 转储,请使用 --encoding=encoding 参数或 PGCLIENTENCODING 环境变量

关于postgresql - 当 .sql 文件是 ANSI 时,pg_dump 是否保留所有 Unicode 字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48468946/

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