utf8_general_ci数据应该如何存储?

发布于 2024-09-30 21:54:33 字数 296 浏览 4 评论 0原文

我正在使用 utf8_general_ci,数据应该如何存储?

我的意思是,如果我有一个 varchar/text 包含特殊字符,例如 áéíóúàèìòùçÇÀÉÌÒ,它们是这样存储的还是以某种方式转换?我正在进行大小写/重音不敏感搜索,但人们告诉我,我没有正确存储数据,所以我需要一个参考,

对此感到困惑,甚至我的 ORDER BY 也不起作用,因为数据已损坏(之后我知道数据应该如何存储,我要转换我的数据库,表/集名称已经是 utf8_general_ci / utf8)

i'm using utf8_general_ci, how should data be stored?

i mean like if i have a varchar/text that contains special chars like áéíóúàèìòùçÇÀÉÌÒ, they are stored like that or they are converted in some way? im making a CASE/ACCENT INSENSITIVE search, but people told me i wasnt properply storing data, so i need a reference

so confused about this, even my ORDER BY is not working because the data is broken (after i know how data should be store im going to convert my database, the tables/setnames are already utf8_general_ci / utf8)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

奈何桥上唱咆哮 2024-10-07 21:54:33

我使用utf8_general_ci,数据应该如何存储?

只要妥善保存即可。 :)

说真的:您应该存储它,以便当您通过 phpMyAdmin 或 HeidiSQL 等程序中的 UTF-8 编码连接查看 UTF-8 编码数据库时,您可以看到实际的字符 áéíóúàèìòùçÇÀÉÌÒ。仅此而已。

utf8_general_ci 已经不区分重音,因为

 á = a
 é = e

如果您使用 LIKE 子句 columnname LIKE "searchterm" 而不是 columnname = "searchterm",它也会不区分大小写。

i'm using utf8_general_ci, how should data be stored?

Just store it properly. :)

Seriously: You should store it so that, when you view the UTF-8 encoded database through an UTF-8 encoded connection in a program like phpMyAdmin or HeidiSQL, you see the actual characters áéíóúàèìòùçÇÀÉÌÒ. Nothing more to it.

utf8_general_ci is already accent insensitive in that

 á = a
 é = e

if you use a LIKE clause columnname LIKE "searchterm" instead of columnname = "searchterm", it will also be case insensitive.

〃温暖了心ぐ 2024-10-07 21:54:33

您确定数据已损坏吗?当你从表格中检索它时,所有的重音符号都丢失了吗? UTF-8是字符集,utf8_general_ci是排序规则。他们是不同的。如果您希望 ORDER BY 真正正确排序,您可能需要使用 utf8_unicode_ci 代替。排序主要是指查找和排序,而不是存储。

你能发布你的 SHOW CREATE TABLE 结果吗?

Are you sure the data is broken? When you retrieve it from the table, are all the accents missing? UTF-8 is a character set, utf8_general_ci is a collation. They're are different. If you want your ORDER BY to truly sort correctly, you may want to use utf8_unicode_ci instead. Collation is mainly in reference to searching and sorting, not storing.

Can you post your SHOW CREATE TABLE result?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文