suchen
HeimDatenbankMySQL-TutorialMySQL 5.7 supports the GB18030 Chinese Character Set_MySQL

My former boss at MySQL sent out a notice that MySQL 5.7.4 nowsupports theGB18030character set, thus responding to requests that have been appearing since2005. This is a big deal because the Chinese government demands GB18030 support, and because the older simplified-Chinese character sets (gbk and gb2312) have a much smaller repertoire (that is, they have too few characters). And this is real GB18030 support -- I can define columns and variables with CHARACTER SET GB18030. That's rare --Oracle 12candSQL Server 2012andPostsgreSQL 9.3can't do it. (They allow input from GB18030 clients but they convert it immediately to Unicode.) Among big-time DBMSs, until now,only DB2has treated GB18030 as a first-class character set.

Standard Adherence

We're talking about the current version of the standard, GB18030-2005 "IT Chinese coded character set", especially its description of 70,244 Chinese characters. I couldn't puzzle out the Chinese wording inthe official document, all I could do was use translate.google.comon some excerpts. But I've been told that the MySQL person who coded this feature is Chinese, so they'll have had better luck. What I could understand was what are the difficult characters, what are the requirements for a claim of support, and what the encoding should look like. From the coder's comments, it's clear that part was understood. I did not check whether there was adherence for non-mandatory parts, such as Tibetan script.

Conversions

The repertoire of GB18030 ought to be the same as the Unicode repertoire. So I took a list of every Unicode character, converted to GB18030, and converted back to Unicode. The result in every case was the same Unicode character that I'd started with. That's called "perfect round tripping". As I explained in an earlier blog post"The UTF-8 World Is Not Enough", storing Chinese characters with a Chinese character set has certain advantages. Well, now the biggest disadvantage has disappeared.

Hold on -- how is perfect round tripping possible, given that MySQLfrequently refers to Unicode 4.0, and some of the characters in GB18030-2005 are only in Unicode 4.1? Certainly that ought to be a problem according to theUnicode FAQandthis extract from Ken Lunde's book. But it turns out to be okay because MySQL doesn't actually disallow those characters -- it accepts encodings which are not assigned to characters. Of course I believe that MySQL should have upgraded the Unicode support first, and added GB18030 support later. But the best must not be an enemy of the good.

Also the conversions to and from gb2312 work fine, so I expect that eventually gb2312 will become obsolete. It's time for mainland Chinese users to consider switching over to gb18030 once MySQL 5.7 is GA.

Collations

The new character set comes with three collations: one trivial, one tremendous, one tsk, tsk.

The trivial collation is gb18030_bin. As always the bin stands for binary. I expect that as always this will be the most performant collation, and the only one that guarantees that no two characters will ever have the same weight.

The tremendous collation is gb18030_unicode_520_ci. The "unicode_520" part of the name really does mean that the collation table comes from"Unicode 5.2"and this is the first time that MySQL has taken to heart the maxim: what applies to the superset can apply to the subset. In fact all MySQL character sets should have Unicode collations, because all their characters are in Unicode. So to test this, I went through all the Unicode characters and their GB18030 equivalents, and compared their weights withWEIGHT_STRING:
WEIGHT_STRING(utf32_char COLLATE utf32_unicode_520_ci) to
WEIGHT_STRING(gb18030_char COLLATE gb18030_unicode_520_ci).
Every utf32 weight was exactly the same as the gb18030 weight.

The tsk, tsk collation is gb18030_chinese_ci.

The first bad thing is the suffix chinese_ci, which will make some people think that this collation is like gb2312_chinese_ci. (Such confusion has happened before for the general_ci suffix.) In fact there are thousands of differences between gb2312_chinese_ci and gb18030_chinese_ci. Here's an example.

mysql> CREATE TABLE t5	->(gb2312 CHAR CHARACTER SET gb2312 COLLATE gb2312_chinese_ci,	-> gb18030 CHAR CHARACTER SET gb18030 COLLATE gb18030_chinese_ci);Query OK, 0 rows affected (0.22 sec)mysql> INSERT INTO t5 VALUES ('[','['),(']',']');Query OK, 2 rows affected (0.01 sec)Records: 2Duplicates: 0Warnings: 0mysql> SELECT DISTINCT gb2312 from t5 ORDER BY gb2312;+--------+| gb2312 |+--------+| ]	|| [	|+--------+2 rows in set (0.00 sec)mysql> SELECT DISTINCT gb18030 from t5 ORDER BY gb18030;+---------+| gb18030 |+---------+| [	 || ]	 |+---------+2 rows in set (0.00 sec)

See the difference? The gb18030 order is obviously better -- ']' should be greater than '[' -- but when two collations are wildly different they shouldn't both be called "chinese_ci".

The second bad thing is the algorithm. The new chinese_ci collation is based onpinyinfor Chinese characters, and binary comparisons of the UPPER() values for non-Chinese characters. This is pretty well useless for non-Chinese. I can bet that somebody will observe "well, duh, it's a Chinese character set" -- but I can't see why one would use an algorithm for Latin/Greek/Cyrillic/etc. characters that's so poor. There's aCommon Locale Data Repositoryfor tailoring for Chinese, there are MySQL worklog tasks that explain the brave new world, there's no need to invent an idiolect when there's a received dialect.

Documentation

The documentation isn't up to date yet -- there's no attempt to explain what the new character set and its collations are about, and no mention at all inthe FAQ.

But the worklog taskWL#4024: gb18030 Chinese character setgives a rough idea of what the coder had in mind before starting. It looks as if WL#4024 was partly copied fromhttp://icu-project.org/docs/papers/unicode-gb18030-faq.htmlso that's also worth a look.

For developers who just need to know what's going on now, just re-read this blog post. What I've described should be enough for people who care about Chinese.

I didn't look for bugs with full-text or LIKE searches, and I didn't look at speed. But I did look hard for problems with the essentials, and found none. Congratulations are due.

Stellungnahme
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
MySQL: Wesentliche Fähigkeiten für Anfänger zu meisternMySQL: Wesentliche Fähigkeiten für Anfänger zu meisternApr 18, 2025 am 12:24 AM

MySQL ist für Anfänger geeignet, um Datenbankfähigkeiten zu erlernen. 1. Installieren Sie MySQL Server- und Client -Tools. 2. Verstehen Sie grundlegende SQL -Abfragen, wie z. B. SELECT. 3.. Stammdatenoperationen: Daten erstellen, Daten einfügen, aktualisieren und löschen. 4. Lernen Sie fortgeschrittene Fähigkeiten: Unterabfragen und Fensterfunktionen. 5. Debugging und Optimierung: Überprüfen Sie die Syntax, verwenden Sie Indizes, vermeiden Sie die Auswahl*und verwenden Sie die Grenze.

MySQL: Strukturierte Daten und relationale DatenbankenMySQL: Strukturierte Daten und relationale DatenbankenApr 18, 2025 am 12:22 AM

MySQL verwaltet strukturierte Daten effizient durch Tabellenstruktur und SQL-Abfrage und implementiert Inter-Tisch-Beziehungen durch Fremdschlüssel. 1. Definieren Sie beim Erstellen einer Tabelle das Datenformat und das Typ. 2. Verwenden Sie fremde Schlüssel, um Beziehungen zwischen Tabellen aufzubauen. 3.. Verbessern Sie die Leistung durch Indexierung und Abfrageoptimierung. 4. regelmäßig Sicherung und Überwachung von Datenbanken, um die Datensicherheit und die Leistungsoptimierung der Daten zu gewährleisten.

MySQL: Schlüsselmerkmale und Funktionen erklärtMySQL: Schlüsselmerkmale und Funktionen erklärtApr 18, 2025 am 12:17 AM

MySQL ist ein Open Source Relational Database Management -System, das in der Webentwicklung häufig verwendet wird. Zu den wichtigsten Funktionen gehören: 1. unterstützt mehrere Speichermotoren wie InnoDB und MyISAM, geeignet für verschiedene Szenarien; 2. Bietet Master-Slave-Replikationsfunktionen, um Lastausgleich und Datensicherung zu erleichtern. 3.. Verbessern Sie die Abfrageeffizienz durch Abfrageoptimierung und Index.

Der Zweck von SQL: Interaktion mit MySQL -DatenbankenDer Zweck von SQL: Interaktion mit MySQL -DatenbankenApr 18, 2025 am 12:12 AM

SQL wird verwendet, um mit der MySQL -Datenbank zu interagieren, um die Datenzusatz, Löschung, Änderung, Inspektion und Datenbankdesign zu realisieren. 1) SQL führt Datenoperationen über SELECT, INSERT, INTERATE, UPDATE, Löschen von Anweisungen durch. 2) Verwenden Sie Anweisungen für Datenbankdesign und -verwaltung create, ändern, fallen. 3) Komplexe Abfragen und Datenanalysen werden über SQL implementiert, um die Effizienz der Geschäftsentscheidungen zu verbessern.

MySQL für Anfänger: Erste Schritte mit der DatenbankverwaltungMySQL für Anfänger: Erste Schritte mit der DatenbankverwaltungApr 18, 2025 am 12:10 AM

Zu den grundlegenden Operationen von MySQL gehört das Erstellen von Datenbanken, Tabellen und die Verwendung von SQL zur Durchführung von CRUD -Operationen für Daten. 1. Erstellen Sie eine Datenbank: createdatabasemy_first_db; 2. Erstellen Sie eine Tabelle: CreateTableBooks (IDINGAUTO_INCRECTIONPRIMARYKEY, Titelvarchar (100) Notnull, AuthorVarchar (100) Notnull, veröffentlicht_yearint); 3.. Daten einfügen: InsertIntoBooks (Titel, Autor, veröffentlicht_year) va

MySQLs Rolle: Datenbanken in WebanwendungenMySQLs Rolle: Datenbanken in WebanwendungenApr 17, 2025 am 12:23 AM

Die Hauptaufgabe von MySQL in Webanwendungen besteht darin, Daten zu speichern und zu verwalten. 1.Mysql verarbeitet effizient Benutzerinformationen, Produktkataloge, Transaktionsunterlagen und andere Daten. 2. Durch die SQL -Abfrage können Entwickler Informationen aus der Datenbank extrahieren, um dynamische Inhalte zu generieren. 3.Mysql arbeitet basierend auf dem Client-Server-Modell, um eine akzeptable Abfragegeschwindigkeit sicherzustellen.

MySQL: Erstellen Sie Ihre erste DatenbankMySQL: Erstellen Sie Ihre erste DatenbankApr 17, 2025 am 12:22 AM

Zu den Schritten zum Erstellen einer MySQL -Datenbank gehören: 1. Erstellen einer Datenbank und Tabelle, 2. Daten einfügen, und 3. Durchführen von Abfragen. Verwenden Sie zunächst die Anweisungen für erstellte und creatEtable, um die Datenbank und Tabelle zu erstellen, und verwenden Sie dann die Anweisung InsertInto, um die Daten einzulegen, und verwenden Sie schließlich die Auswahlanweisung, um die Daten abzufragen.

MySQL: Ein anfängerfreundlicher Ansatz zur DatenspeicherungMySQL: Ein anfängerfreundlicher Ansatz zur DatenspeicherungApr 17, 2025 am 12:21 AM

MySQL ist für Anfänger geeignet, da es einfach zu bedienen und leistungsfähig ist. 1.Mysql ist eine relationale Datenbank und verwendet SQL für CRUD -Operationen. 2. Es ist einfach zu installieren und erfordert, dass das Stammbenutzerkennwort konfiguriert wird. 3.. Verwenden Sie Einfügen, Aktualisieren, Löschen und Wählen Sie, um Datenvorgänge auszuführen. 4. OrderBy, wo und Join kann für komplexe Abfragen verwendet werden. 5. Debugging erfordert die Überprüfung der Syntax und verwenden Sie Erklärungen zur Analyse der Abfrage. 6. Die Optimierungsvorschläge umfassen die Verwendung von Indizes, die Auswahl des richtigen Datentyps und der guten Programmiergewohnheiten.

See all articles

Heiße KI -Werkzeuge

Undresser.AI Undress

Undresser.AI Undress

KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover

AI Clothes Remover

Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool

Undress AI Tool

Ausziehbilder kostenlos

Clothoff.io

Clothoff.io

KI-Kleiderentferner

AI Hentai Generator

AI Hentai Generator

Erstellen Sie kostenlos Ai Hentai.

Heißer Artikel

R.E.P.O. Energiekristalle erklärten und was sie tun (gelber Kristall)
1 Monate vorBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Beste grafische Einstellungen
1 Monate vorBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Crossplay haben?
1 Monate vorBy尊渡假赌尊渡假赌尊渡假赌

Heiße Werkzeuge

SublimeText3 Linux neue Version

SublimeText3 Linux neue Version

SublimeText3 Linux neueste Version

EditPlus chinesische Crack-Version

EditPlus chinesische Crack-Version

Geringe Größe, Syntaxhervorhebung, unterstützt keine Code-Eingabeaufforderungsfunktion

PHPStorm Mac-Version

PHPStorm Mac-Version

Das neueste (2018.2.1) professionelle, integrierte PHP-Entwicklungstool

MinGW – Minimalistisches GNU für Windows

MinGW – Minimalistisches GNU für Windows

Dieses Projekt wird derzeit auf osdn.net/projects/mingw migriert. Sie können uns dort weiterhin folgen. MinGW: Eine native Windows-Portierung der GNU Compiler Collection (GCC), frei verteilbare Importbibliotheken und Header-Dateien zum Erstellen nativer Windows-Anwendungen, einschließlich Erweiterungen der MSVC-Laufzeit zur Unterstützung der C99-Funktionalität. Die gesamte MinGW-Software kann auf 64-Bit-Windows-Plattformen ausgeführt werden.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Leistungsstarke integrierte PHP-Entwicklungsumgebung