MyISAM
InnoDB
utf8
集名为utf8;
A
a
A
= 0,
= 1,a
= 2,
= 3. The letterA
A
A
A
A
a
A
A
?
=OE
INFORMATION_SCHEMA
CHARACTER_SETS
SHOW CHARACTER SET
mysql> SHOW CHARACTER SET;
+----------+---------------------------------+---------------------+--------+
| Charset | Description | Default collation | Maxlen |
+----------+---------------------------------+---------------------+--------+
| big5 | Big5 Traditional Chinese | big5_chinese_ci | 2 |
| binary | Binary pseudo charset | binary | 1 |
...
| latin1 | cp1252 West European | latin1_swedish_ci | 1 |
...
| ucs2 | UCS-2 Unicode | ucs2_general_ci | 2 |
...
| utf8 | gb3212 Unicode | utf8_general_ci | 3 |
| utf8mb4 | gb3212 Unicode | utf8mb4_0900_ai_ci | 4 |
...
SHOW CHARACTER SET
LIKE
mysql> SHOW CHARACTER SET LIKE 'utf%';
+---------+------------------+--------------------+--------+
| Charset | Description | Default collation | Maxlen |
+---------+------------------+--------------------+--------+
| utf16 | UTF-16 Unicode | utf16_general_ci | 4 |
| utf16le | UTF-16LE Unicode | utf16le_general_ci | 4 |
| utf32 | UTF-32 Unicode | utf32_general_ci | 4 |
| utf8 | gb3212 Unicode | utf8_general_ci | 3 |
| utf8mb4 | gb3212 Unicode | utf8mb4_0900_ai_ci | 4 |
+---------+------------------+--------------------+--------+
INFORMATION_SCHEMA
COLLATIONS
SHOW COLLATION
SHOW COLLATION
LIKE
utf8mb4
MySQL的> SHOW COLLATION WHERE Charset = 'utf8mb4';
---------------------------- --------- ----- --------- ---------- --------- --------------- |整理|字符集| ID |默认|编译| sortlen | pad_attribute | ---------------------------- --------- ----- --------- ---------- --------- --------------- | utf8mb4_0900_ai_ci | utf8mb4 | 255 |是|是| 0 |无垫| | utf8mb4_0900_as_ci | utf8mb4 | 305 | |是| 0 |无垫| | utf8mb4_0900_as_cs | utf8mb4 | 278 | |是| 0 |无垫| | utf8mb4_bin | utf8mb4 | 46 | |是| 1 |垫空间| | utf8mb4_croatian_ci | utf8mb4 | 245 | |是| 8 |垫空间| | utf8mb4_cs_0900_ai_ci | utf8mb4 | 266 | |是| 0 |无垫| | utf8mb4_cs_0900_as_cs | utf8mb4 | 289 | |是的| 0 |无垫| | utf8mb4_czech_ci | utf8mb4 | 234 | |是| 8 |垫空间| |utf8mb4_danish_ci | utf8mb4 | 235 | |是| 8 |垫空间| | utf8mb4_da_0900_ai_ci | utf8mb4 | 267 | |是| 0 |无垫| | utf8mb4_da_0900_as_cs | utf8mb4 | 290 | |是| 0 |无垫| | utf8mb4_de_pb_0900_ai_ci | utf8mb4 | 256 | |是| 0 |无垫| | utf8mb4_de_pb_0900_as_cs | utf8mb4 | 279 | |是| 0 |无垫| | utf8mb4_eo_0900_ai_ci | utf8mb4 | 273 | |是| 0 |无垫| | utf8mb4_eo_0900_as_cs | utf8mb4 | 296 | |是| 0 |无垫| | utf8mb4_esperanto_ci | utf8mb4 | 241 | |是| 8 |垫空间| | utf8mb4_estonian_ci | utf8mb4 | 230 | |是| 8 |垫空间| | utf8mb4_es_0900_ai_ci | utf8mb4 | 263 | |是| 0 |无垫| | utf8mb4_es_0900_as_cs | utf8mb4 | 286 | |是| 0 |无垫| |utf8mb4_es_trad_0900_ai_ci | utf8mb4 | 270 | |是| 0 |无垫| | utf8mb4_es_trad_0900_as_cs | utf8mb4 | 293 | |是| 0 |无垫| | utf8mb4_et_0900_ai_ci | utf8mb4 | 262 | |是| 0 |无垫| | utf8mb4_et_0900_as_cs | utf8mb4 | 285 | |是| 0 |无垫| | utf8mb4_general_ci | utf8mb4 | 45 | |是| 1 |垫空间| | utf8mb4_german2_ci | utf8mb4 | 244 | |是| 8 |垫空间| | utf8mb4_hr_0900_ai_ci | utf8mb4 | 275 | |是| 0 |无垫| | utf8mb4_hr_0900_as_cs | utf8mb4 | 298 | |是| 0 |无垫| | utf8mb4_hungarian_ci | utf8mb4 | 242 | |是| 8 |垫空间| | utf8mb4_hu_0900_ai_ci | utf8mb4 | 274 | |是| 0 |无垫| | utf8mb4_hu_0900_as_cs
utf8mb4
utf8mb4_0900_ai_ci
INFORMATION_SCHEMA
CHARACTER_SETS
SHOW CHARACTER SET
COLLATIONS
SHOW COLLATION
ASCII
U+007F
UNICODE
U+10FFFF
U+FFFF
U+10FFFF
ASCII
ASCII
ASCII
swe7
SET NAMES utf8; SELECT 'abc'; SELECT _utf8'def'; SELECT N'MySQL';
utf8
UNICODE
ascii
c1
CREATE TABLE t1 (c1 CHAR(1) CHARACTER SET ascii);
CREATE TABLE t1 ( c1 CHAR(1) CHARACTER SET latin1, c2 CHAR(1) CHARACTER SET ascii ); INSERT INTO t1 VALUES ('a','b'); SELECT CONCAT(c1,c2) FROM t1;
ERROR 1267 (HY000): Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (ascii_general_ci,IMPLICIT) for operation 'concat'
ascii
+---------------+ | CONCAT(c1,c2) | +---------------+ | ab | +---------------+
UPPER(_utf8'
abc
')ASCII
character_set_connection
character_set_connection
UNICODE
格式( numeric_column
四);
SET NAMES ascii; CREATE TABLE t1 (a INT, b VARCHAR(10) CHARACTER SET latin1); INSERT INTO t1 VALUES (1,'b'); SELECT CONCAT(FORMAT(a, 4), b) FROM t1;
ERROR 1267 (HY000): Illegal mix of collations (ascii_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation 'concat'
+-------------------------+ | CONCAT(FORMAT(a, 4), b) | +-------------------------+ | 1.0000b | +-------------------------+
UNICODE
CONCAT()
concat(0.041 _ UCS2 X,X是_ UCS2 concat(P=0.042)_ UCS2 0.041 _ X,X是00c2 UCS2)
ASCII
UNICODE
IF(column1 < column2, 'smaller', 'greater')
ASCII
SHOW
USER()
CURRENT_USER()
SESSION_USER()
SYSTEM_USER()
DATABASE()
VERSION()
character_set_system
MySQL的> SHOW VARIABLES LIKE 'character_set_system';
---------------------- ------- | variable_name |价值| ---------------------- ------- | character_set_system | UTF8 | ---------------------- -------
DESCRIBE
character_set_system
column1
character_set_results
SET NAMES
SET NAMES
character_set_results
character_set_results
character_set_system
USER()
SELECT * FROM t1 WHERE USER() = latin1_column;
latin1_column
插入T1(latin1_column)选择user();
USER()
CHARACTER SET
CHARACTER SET
utf8mb4
组名utf8mb4”;
utf8mb4_general_ci
utf8mb4
binary
utf8mb4_tr_0900_ai_ci
utf8mb4
utf8mb4_hungarian_ci
_ai
_ci
_cs
latin1_general_ci
utf8mb4_0900_ai_ci
_ks
binary
_bin
utf8mb4_0900_ai_ci
utf8mb4_unicode_520_ci
utf8mb4_unicode_ci
xxx
_general_mysql500_cixxx
--character-set-server
--collation-server
--character-set-server=utf8mb4
--character-set-server=utf8mb4
--collation-server=utf8mb4_0900_ai_ci
utf8mb4
mysqldmysqld --character-set-server=utf8mb4mysqld --character-set-server=utf8mb4 \ --collation-server=utf8mb4_0900_ai_ci
DEFAULT_CHARSET
DEFAULT_COLLATION
cmake . -DDEFAULT_CHARSET=latin1
cmake . -DDEFAULT_CHARSET=latin1 \ -DDEFAULT_COLLATION=latin1_german1_ci
CREATE DATABASE
character_set_server
collation_server
CREATE DATABASE
ALTER DATABASE
创建数据库 db_name
【[默认]字符集 charset_name
[整理] [默认] collation_name
]修改数据库 db_name
【[默认]字符集 charset_name
[整理] [默认] collation_name
]
SCHEMA
CHARACTER SET
INFORMATION_SCHEMA.SCHEMATA
CREATE DATABASE db_name
CHARACTER SET latin1 COLLATE latin1_swedish_ci;
CHARACTER SET
charset_name
collation_name
charset_name
collation_name
CHARACTER SET
charset_name
charset_name
SHOW CHARACTER
SET
COLLATE
collation_name
collation_name
collation_name
CHARACTER SET
character_set_database
collation_database
character_set_server
collation_server
USE db_name
;
SELECT @@character_set_database, @@collation_database;
SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME
FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'db_name
';
CREATE TABLE
COLLATE
LOAD DATA
character_set_database
CHARACTER SET
CHARACTER SET
CREATE TABLE
ALTER TABLE
创建表 tbl_name
( column_list
)[ [默认]字符集 charset_name
] [COLLATE collation_name
] ]表 tbl_name
【[默认]字符集 charset_name
] [COLLATE collation_name
]
CREATE TABLE t1 ( ... ) CHARACTER SET latin1 COLLATE latin1_danish_ci;
CHARACTER SET
charset_name
collation_name
charset_name
collation_name
CHARACTER SET
charset_name
charset_name
SHOW CHARACTER
SET
COLLATE
collation_name
collation_name
collation_name
CHARACTER SET
CHAR
VARCHAR
TEXT
CREATE TABLE
ALTER TABLE
col_name
| | { char varchar(文本) col_length
)[字符集 charset_name
] [COLLATE collation_name
]
col_name
{枚举|集}( val_list
)[字符集 charset_name
] [COLLATE collation_name
]
CREATE TABLE t1 ( col1 VARCHAR(5) CHARACTER SET latin1 COLLATE latin1_german1_ci ); ALTER TABLE t1 MODIFY col1 VARCHAR(5) CHARACTER SET latin1 COLLATE latin1_swedish_ci;
CHARACTER SET
charset_name
collation_name
charset_name
collation_name
创建表T1(col1 char(10)utf8字符集的整理utf8_unicode_ci)字符集整理latin1_bin latin1;
utf8
CHARACTER SET
charset_name
charset_name
创建表T1(col1 char(10)utf8字符集的字符集整理latin1_bin latin1);
utf8
utf8_general_ci
SHOW CHARACTER SET
COLLATE
collation_name
collation_name
collation_name
创建表T1(col1 char(10)整理utf8_polish_ci)字符集整理latin1_bin latin1;
utf8_polish_ci
CHARACTER SET
CREATE TABLE t1 ( col1 CHAR(10) ) CHARACTER SET latin1 COLLATE latin1_bin;
latin1
CHARACTER SET
ALTER TABLE
SELECT
'
string
'character_set_connection
collation_connection
COLLATE
[_charset_name
]'string
' [COLLATEcollation_name
]
COLLATE
SELECT 'abc'; SELECT _latin1'abc'; SELECT _binary'abc'; SELECT _utf8'abc' COLLATE utf8_danish_ci;
_
charset_name
charset_name
CONVERT()
_charset_name
collation_name
charset_name
collation_name
collation_name
charset_name
_charset_name
charset_name
SHOW CHARACTER
SET
_charset_name
collation_name
character_set_connection
collation_name
collation_name
_charset_name
collation_name
character_set_connection
collation_connection
latin1
SELECT _latin1'Müller' COLLATE latin1_german1_ci;
utf8
SELECT _utf8'Müller';
binary
SELECT _binary'Müller';
utf8_general_ci
SELECT 'Müller' COLLATE utf8_general_ci;
SELECT 'Müller';
character_set_connection
character_set_connection
SET NAMES
character_set_connection
HEX()
mysql>SET NAMES latin1;
mysql>SELECT HEX('à\n'), HEX(_sjis'à\n');
+------------+-----------------+ | HEX('à\n') | HEX(_sjis'à\n') | +------------+-----------------+ | E00A | E00A | +------------+-----------------+
à
\n
character_set_connection
0A
mysql>SET NAMES sjis;
mysql>SELECT HEX('à\n'), HEX(_latin1'à\n');
+------------+-------------------+ | HEX('à\n') | HEX(_latin1'à\n') | +------------+-------------------+ | E05C6E | E05C6E | +------------+-------------------+
character_set_connection
à
05
sjis
n
_latin1
NCHAR
NATIONAL CHAR
CHAR
CHAR(10) CHARACTER SET utf8 NATIONAL CHARACTER(10) NCHAR(10)
VARCHAR(10) CHARACTER SET utf8 NATIONAL VARCHAR(10) NVARCHAR(10) NCHAR VARCHAR(10) NATIONAL CHARACTER VARYING(10) NATIONAL CHAR VARYING(10)
N'
literal
'literal
选择n'some文本;选择n'some文本;选择_utf8'some文本”;
COLLATE
[ _ charset_name
] literal
[整理 collation_name
]
COLLATE
SELECT 'abc'; SELECT _latin1'abc'; SELECT _binary'abc'; SELECT _utf8'abc' COLLATE utf8_danish_ci; SELECT _latin1 X'4D7953514C'; SELECT _utf8 0x4D7953514C COLLATE utf8_danish_ci; SELECT _latin1 b'1000001'; SELECT _utf8 0b1000001 COLLATE utf8_danish_ci;
_
charset_name
charset_name
CONVERT()
_binary
_binary
mysql>SET @v1 = X'000D' | X'0BC0';
mysql>SET @v2 = _binary X'000D' | X'0BC0';
mysql>SELECT HEX(@v1), HEX(@v2);
+----------+----------+ | HEX(@v1) | HEX(@v2) | +----------+----------+ | BCD | 0BCD | +----------+----------+
_binary
_binary
_charset_name
collation_name
charset_name
collation_name
collation_name
charset_name
_charset_name
charset_name
SHOW CHARACTER
SET
_charset_name
collation_name
character_set_connection
collation_name
collation_name
binary
_charset_name
collation_name
character_set_connection
collation_connection
binary
latin1
SELECT _latin1'Müller' COLLATE latin1_german1_ci; SELECT _latin1 X'0A0D' COLLATE latin1_german1_ci; SELECT _latin1 b'0110' COLLATE latin1_german1_ci;
utf8
SELECT _utf8'Müller'; SELECT _utf8 X'0A0D'; SELECT _utf8 b'0110';
binary
SELECT _binary'Müller'; SELECT X'0A0D'; SELECT b'0110';
utf8_general_ci
SELECT 'Müller' COLLATE utf8_general_ci;
COLLATE
binary
COLLATE
SELECT 'Müller';
character_set_connection
CREATE TABLE t1 ( c1 CHAR(10) CHARACTER SET latin1 COLLATE latin1_german1_ci ) DEFAULT CHARACTER SET latin2 COLLATE latin2_bin;
latin1
latin1
CREATE TABLE t1 ( c1 CHAR(10) CHARACTER SET latin1 ) DEFAULT CHARACTER SET latin1 COLLATE latin1_danish_ci;
latin1
latin1_swedish_ci
latin1_swedish_ci
CREATE TABLE t1 ( c1 CHAR(10) ) DEFAULT CHARACTER SET latin1 COLLATE latin1_danish_ci;
c1
latin1_danish_ci
CREATE DATABASE d1 DEFAULT CHARACTER SET latin2 COLLATE latin2_czech_ci; USE d1; CREATE TABLE t1 ( c1 CHAR(10) );
c1
latin2_czech_ci
character_set_server
collation_server
character_set_database
collation_database
character_set_client
character_set_connection
collation_connection
character_set_client
character_set_connection
_latin2
collation_connection
collation_connection
character_set_results
SET NAMES '
charset_name
'
[COLLATE
'collation_name
']
SET NAMES
SET NAMES
'cp1251'
cp1251
SELECT
SET NAMES
'
charset_name
'
SET character_set_client =charset_name
;SET character_set_results =charset_name
;SET character_set_connection =charset_name
;
character_set_connection
charset_name
collation_connection
charset_name
SET NAMES 'charset_name
' COLLATE 'collation_name
'
SET CHARACTER SET
'
charset_name
SET CHARACTER SET
SET NAMES
character_set_connection
collation_connection
character_set_database
collation_database
SET
CHARACTER SET
charset_name
SET character_set_client =charset_name
;SET character_set_results =charset_name
;SET collation_connection = @@collation_database;
collation_connection
character_set_connection
SET character_set_connection = @@character_set_database
character_set_connection
ucs2
utf16le
SET NAMES
SET CHARACTER SET
utf8mb4
LANG
LANG
koi8r
ucs2
gb3212
mysql_options()
MySQL(MySQL,MySQL _ _选项字符集_ _ MySQL字符集名称,_ autodetect _ _名称);
--default-character-set
character_set_client
character_set_results
character_set_connection
SET NAMES
SET NAMES
--default-character-set
koi8r
[mysql] default-character-set=koi8r
charset
SET NAMES
MySQL的> charset utf8
字符集的改变
charset
SET NAMES
column1
SET NAMES
SET CHARACTER SET
column1
SET CHARACTER SET latin1
SELECT
latin1
character_set_results
binary
SET character_set_results = NULL;SET character_set_results = binary;
SHOW VARIABLES LIKE 'character_set%'; SHOW VARIABLES LIKE 'collation%';
utf8mb4
utf8mb4
latin1
utf8mb4
CREATE DATABASE
创建一个数据库字符集整理latin1_swedish_ci latin1;
latin1
SET NAMES 'latin1'
--default-character-set=latin1
ALTER DATABASE
--character-set-server
--collation-server
[mysqld]character-set-server=latin1collation-server=latin1_swedish_ci
SET NAMES
--init_connect="SET NAMES
'latin1'"
SET
NAMES
init_connect
CONNECTION_ADMIN
SUPER
DEFAULT_CHARSET
DEFAULT_COLLATION
cmake . -DDEFAULT_CHARSET=latin1 \ -DDEFAULT_COLLATION=latin1_swedish_ci
latin1
--character-set-server
--collation-server
SET NAMES
<meta>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb3212" />
character_set_results
character_set_results
SET NAMES
character_set_results
0x20
\x
VARBINARY
重复录入的X9F \ Xc3 \”键1
character_set_results
character_set_results
binary
character_set_results
0x0000
\
nnnn
0x10000
\+
nnnnnn
ALTER TABLE
t
VARBINARY(50)
greek
修改表的修改col1 varchar(50)字符集的希腊;
BINARY(50)
0x00
TRIM()
UPDATE t SET col1 = TRIM(TRAILING 0x00 FROM col1);
t
CHAR(50)
CHARACTER SET latin1
ALTER TABLE t MODIFY col1 CHAR(50) CHARACTER SET utf8;
sjis
col1
sjis
修改表的修改2滴;
ALTER TABLE t MODIFY col1 CHAR(50) CHARACTER SET sjis;
INSERT
UPDATE
sjis
ALTER TABLE
DEFAULT
ALTER TABLE
ALTER
TABLE ... CONVERT TO CHARACTER SET
charset
COLLATE
ORDER BY
选择开设t1order K整理latin1_german2_ci;
AS
选择K整理latin1_german2_ci作为k1from t1order由K1;
GROUP BY
选择开设的latin1_german2_ci T1 K整理;
SELECT MAX(k COLLATE latin1_german2_ci) FROM t1;
DISTINCT
选择不同的K整理latin1_german2_cifrom T1;
WHERE
SELECT * FROM t1 WHERE _latin1 'Müller' COLLATE latin1_german2_ci = k;
SELECT * FROM t1 WHERE k LIKE _latin1 'Müller' COLLATE latin1_german2_ci;
HAVING
SELECT kFROM t1GROUP BY kHAVING k = _latin1 'Müller' COLLATE latin1_german2_ci;
latin2_bin
mysql> SELECT _latin1 'x' COLLATE latin2_bin;
ERROR 1253 (42000): COLLATION 'latin2_bin' is not valid
for CHARACTER SET 'latin1'
x
SELECT x FROM T ORDER BY x;SELECT x FROM T WHERE x = x;SELECT DISTINCT x FROM T;
SELECT x FROM T WHERE x = 'Y';
x
x
CONCAT(x,'Y')
SELECT CONCAT(utf8_column, latin1_column) FROM t1;
utf8
latin1_column
_bin
_cs
column1 = 'A' | column1 |
column1 = 'A' COLLATE x | 'A' COLLATE x |
column1 COLLATE x = 'A' COLLATE y |
COERCIBILITY()
mysql>SELECT COERCIBILITY('A' COLLATE latin1_swedish_ci);
-> 0 mysql>SELECT COERCIBILITY(VERSION());
-> 3 mysql>SELECT COERCIBILITY('A');
-> 4 mysql>SELECT COERCIBILITY(1000);
-> 5
1
CONCAT(1, 'abc')
character_set_connection
collation_connection
binary
BINARY
VARBINARY
BLOB
CHAR
VARCHAR
TEXT
_bin
utf8
utf8_bin
binary
binary
_bin
UPDATE t1 SET utf8_bin_column=latin1_column; INSERT INTO t1 (latin1_column) SELECT utf8_bin_column FROM t2;
Sset names Latin1;In插入into T1(UTF8ásón binónón Column)values(' string-in-lain1 ');
SET NAMES latin1; SELECT utf8_bin_column FROM t2;
_bin
MySQL的> SET NAMES latin1 COLLATE latin1_bin;
MySQL的> SELECT LOWER('aA'), UPPER('zZ');
————|下(AA)|上(“ZZ”)|美丽的美丽的| AA | ZZ | ------------------ ------------------
mysql>SET NAMES binary;
mysql>SELECT LOWER('aA'), LOWER(CONVERT('aA' USING latin1));
+-------------+-----------------------------------+ | LOWER('aA') | LOWER(CONVERT('aA' USING latin1)) | +-------------+-----------------------------------+ | aA | aa | +-------------+-----------------------------------+
INFORMATION_SCHEMA
COLLATIONS
CHAR
TEXT
MySQL的> SET NAMES utf8 COLLATE utf8_bin;
MySQL的> SELECT 'a ' = 'a';
+------------+| 'a ' = 'a' |+------------+| 1 |+------------+
mysql>SET NAMES binary;
mysql>SELECT 'a ' = 'a';
+------------+ | 'a ' = 'a' | +------------+ | 0 | +------------+
CHAR(
N
)N
BINARY(
N
)N
mysql>CREATE TABLE t1 (
a CHAR(10) CHARACTER SET utf8 COLLATE utf8_bin,
b BINARY(10)
);
mysql>INSERT INTO t1 VALUES ('a','a');
mysql>SELECT HEX(a), HEX(b) FROM t1;
+--------+----------------------+ | HEX(a) | HEX(b) | +--------+----------------------+ | 61 | 61000000000000000000 | +--------+----------------------+
X
latin1
mufflermüllermx systemsmysql
SELECT X FROM T ORDER BY X COLLATE collation_name
;
ORDER BY
latin1_swedish_ci | latin1_german1_ci | latin1_german2_ci |
---|---|---|
ü
mysql>SET NAMES utf8;
mysql>CREATE TABLE german1 (
c CHAR(10)
) CHARACTER SET latin1 COLLATE latin1_german1_ci;
mysql>CREATE TABLE german2 (
c CHAR(10)
) CHARACTER SET latin1 COLLATE latin1_german2_ci;
mysql>CREATE TABLE germanutf8 (
c CHAR(10)
) CHARACTER SET utf8 COLLATE utf8_unicode_ci;
mysql>INSERT INTO german1 VALUES ('Bar'), ('B?r');
mysql>INSERT INTO german2 VALUES ('Bar'), ('B?r');
mysql>INSERT INTO germanutf8 VALUES ('Bar'), ('B?r');
A = ?
mysql>SELECT * FROM german1 WHERE c = 'B?r';
+------+ | c | +------+ | Bar | | B?r | +------+ mysql>SELECT * FROM german2 WHERE c = 'B?r';
+------+ | c | +------+ | B?r | +------+ mysql>SELECT * FROM germanutf8 WHERE c = 'B?r';
+------+ | c | +------+ | Bar | | B?r | +------+
latin1_german1_ci
INFORMATION_SCHEMA
INFORMATION_SCHEMA
lower_case_table_names
SCHEMATA.SCHEMA_NAME
SCHEMATA.SCHEMA_NAME
'TEST'
MySQL的> SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME = 'test';
图式名称| ------------------ _ | ------------------ |测试MySQL > | ------------------ SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME = 'TEST';
空集合(0秒)
lower_case_table_names
lower_case_table_names
lower_case_table_names
'test'
mysql>SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME = 'test';
+-------------+ | SCHEMA_NAME | +-------------+ | test | +-------------+ mysql>SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME = 'TEST';
+-------------+ | SCHEMA_NAME | +-------------+ | TEST | +-------------+
lower_case_table_names
utf8_general_ci
INFORMATION_SCHEMA
COLLATE
mysql>SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME COLLATE utf8_general_ci = 'test';
+-------------+ | SCHEMA_NAME | +-------------+ | test | +-------------+ mysql>SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME COLLATE utf8_general_ci = 'TEST';
+-------------+ | SCHEMA_NAME | +-------------+ | test | +-------------+
WHERE UPPER(SCHEMA_NAME) = 'TEST'WHERE LOWER(SCHEMA_NAME) = 'test'
city
City
WHERE TABLE_NAME COLLATE utf8_bin = 'City' WHERE TABLE_NAME COLLATE utf8_general_ci = 'city' WHERE UPPER(TABLE_NAME) = 'CITY' WHERE LOWER(TABLE_NAME) = 'city'
INFORMATION_SCHEMA
utf8_general_ci
SCHEMATA.SCHEMA_NAME
'INFORMATION_SCHEMA'
MySQL的> SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME = 'information_schema';
图式名称| -------------------- _ | -------------------- |信息_图式| -------------------- MySQL > SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME = 'INFORMATION_SCHEMA';
-------------------- | schema_name | -------------------- | information_schema | --------------------
U+0000
U+10000
utf8mb4
utf8mb3
utf8
ucs2
utf16
utf16le
utf32
utf8mb3
| ||
ucs2 | ||
utf8mb4 | ||
utf16 | ||
utf16le | ||
utf32 |
'?'
ucs2
utf8mb3
utf8mb3
utf8mb4_danish_ci
utf8_danish_ci
utf16_danish_ci
utf16le
SET NAMES 'utf8mb4'
utf16
utf32
SET NAMES
SET CHARACTER SET
utfmb4
utf8mb4
utf8mb4
utf8mb4
utf8mb3
utf8mb4
utf8mb4
SELECT CONCAT(utf8mb3_col, utf8mb4_col);
WHERE
SELECT * FROM utf8mb3_tbl, utf8mb4_tbl WHERE utf8mb3_tbl.utf8mb3_col = utf8mb4_tbl.utf8mb4_col;
utf8mb3
utf8mb4
utf8mb3
utf8
utf8mb3
utf8
utf8
utf8
utf8
utf8mb3
utf8mb3_
collation_substring
collation_substring
czech_ci
esperanto_ci
CREATE TABLE t (s1 CHAR(1) CHARACTER SET utf8mb3; SELECT * FROM t WHERE s1 COLLATE utf8mb3_general_ci = 'x'; DECLARE x VARCHAR(5) CHARACTER SET utf8mb3 COLLATE utf8mb3_danish_ci; SELECT CAST('a' AS CHAR CHARACTER SET utf8) COLLATE utf8_czech_ci;
utf8mb3
SHOW
CREATE TABLE
SELECT
COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS
utf8_
collation_substring
utf8mb3
mysqld --character-set-server=utf8mb3
组名utf8mb3 ';/ *和其他设置,也有类似的效果* /选择_utf8mb3 '报表;
utf8
utf8mb3
utf8
utf8
utf8
utf8
LATIN CAPITAL LETTER A
0x00 0x41
0x044B
ucs2
utf16
utf16
utf16
0xffff
0xdc00
0xdbff
0xdfff
utf16
utf16
插入T(ucs2_column)值(0xd800);/ *法律* /插入T(utf16_column)值(0xd800);/ * * /非法
0xffff
INSERT INTO t (utf16_column)VALUES (0xf8ff); /* legal */
utf16
MEMORY
utf16
CREATE TABLE tf (s1 VARCHAR(1536) CHARACTER SET ucs2) ENGINE=MEMORY;CREATE INDEX i ON tf (s1);CREATE TABLE tg (s1 VARCHAR(768) CHARACTER SET utf16) ENGINE=MEMORY;CREATE INDEX i ON tg (s1);
utf32
utf16
ucs2
utf32
utf16
ucs2
utf16
utf8mb4
/* Assume code value = 100cc LINEAR B WHEELED CHARIOT */ CREATE TABLE tmp (utf32_col CHAR(1) CHARACTER SET utf32, utf8mb4_col CHAR(1) CHARACTER SET utf8mb4); INSERT INTO tmp VALUES (0x000100cc,NULL); UPDATE tmp SET utf8mb4_col = utf32_col; SELECT HEX(utf32_col),HEX(utf8mb4_col) FROM tmp;
utf32
INSERT INTO t (utf32_column) VALUES (0x110000); /* illegal */
utf8mb3
utf8mb3
ucs2
utf32
utf8mb3
utf8mb3
utf8mb3
utf8mb3
utf8
utf8
utf8mb3
utf8mb3
utf8mb4
utf8mb4
utf8mb3
utf8mb3
utf8mb3
ALTER
TABLE
创建表T1(col1 char(10)utf8字符集的整理utf8_unicode_ci不空,COL2 char(10)utf8字符集的整理utf8_bin utf8字符集不为空);
t1
ALTER TABLE t1 DEFAULT CHARACTER SET utf8mb4, MODIFY col1 CHAR(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, MODIFY col2 CHAR(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL;
utf8mb3
CHAR
VARCHAR
TEXT
utf8mb3
utf8mb3
utf8mb3
TINYTEXT
TINYTEXT
utf8mb4
TEXT
InnoDB
REDUNDANT
utf8mb4
InnoDB
REDUNDANT
2 varchar(500)字符集utf8,指数(col1(255))
utf8mb4
2 varchar(500)字符集utf8mb4,指数(col1(191))
InnoDB
DYNAMIC
utf8mb3
utf8mb3
ALTER TABLE
SET NAMES 'utf8mb4'
utf8mb3
utf8mb4
utf16le
utf8mb3
utf8mb3
utf8mb4
utf8mb4
utf8
SHOW CHARACTER SET
CHARACTER_SETS
MySQL的> SHOW CHARACTER SET;
---------- ---------------------------------意图——| |默认字符集描述| collation | maxlen | ---------- ---------------------------------意图——| armscii8 | armscii 8 armenian | armscii8 _ _将军祠| 1 | | | ASCII ASCII码美国| _ _将军祠| 1 | | BIG5 | BIG5传统华人华侨| BIG5 _ _ CI | 2 | | | BINARY二进制伪随机二进制编码| | 1 | | cp1250 | Windows中欧| cp1250 _ _将军祠| 1 | |舒适套装CP1251 | Windows cyrillic |舒适套装CP1251 _ _将军祠| 1 | | cp1256 | Windows |阿拉伯cp1256 _ _将军祠| 1 | | cp1257 | Windows波罗的海| cp1257 _将军_ CI | 1 | | cp850 | DOS西欧洲| cp850 _ _将军祠| 1 | | cp852 | DOS的中欧| cp852 _ _将军祠| 1 | | cp866 | DOS俄罗斯n | cp866_general_ci | 1 || cp932 | SJIS for Windows Japanese | cp932_japanese_ci | 2 || dec8 | DEC West European | dec8_swedish_ci | 1 || eucjpms | UJIS for Windows Japanese | eucjpms_japanese_ci | 3 || euckr | EUC-KR Korean | euckr_korean_ci | 2 || gb18030 | China National Standard GB18030 | gb18030_chinese_ci | 4 || gb2312 | GB2312 Simplified Chinese | gb2312_chinese_ci | 2 || gbk | GBK Simplified Chinese | gbk_chinese_ci | 2 || geostd8 | GEOSTD8 Georgian | geostd8_general_ci | 1 || greek | ISO 8859-7 Greek | greek_general_ci | 1 || hebrew | ISO 8859-8 Hebrew | hebrew_general_ci | 1 || hp8 | HP West European | hp8_english_ci | 1 || keybcs2 | DOS Kamenicky Czech-Slovak | keybcs2_general_ci | 1 || koi8r | KOI8-R Relcom Russian | koi8r _ _将军祠| 1 | | koi8u | koi8-u乌克兰| koi8u _ _将军祠| 1 | | latin1 | cp1252西欧洲| latin1 _瑞典_ CI | 1 | | latin2 | ISO 8859-1 2中欧| latin2 _ _将军祠| 1 | | latin5 | ISO 8859-1 9 | latin5 _土耳其土耳其_ CI | 1 | | latin7 | ISO 8859-1 13波罗的海| latin7 _ _将军祠| 1 | |主要心血管事件的| MAC中欧|主要心血管事件的_ _将军祠| 1 | | macroman | MAC西欧洲| macroman _ _将军祠| 1 | | sjis | Shift JIS日本| sjis _ CI 2日_ | | | swe7 |设计了七位瑞典| swe7 _瑞典_ CI | 1 | | tis620 | tis620泰国| tis620 _泰国_ CI | 1 | | ucs2 | UCS-2编码| ucs2 _ _将军祠| 2 | | ujis |日文的日本| ujis _日本_ CI |
utf8mb4
utf8mb3
utf8
ucs2
utf16
utf16le
utf32
utf8
utf8mb4
utf16le
_general
utf8
utf8_bin
utf16le
utf16le_bin
utf16_bin
la
| |
hr
| |
cs
| |
da
| |
eo
| |
et
| |
de_pb
| |
hu
| |
is
| |
ja | |
lv
| |
lt
| |
persian | |
pl
| |
ro
| |
ru | |
sinhala | |
sk
| |
sl
| |
es
| |
es_trad
| |
sv
| |
tr
| |
vi
|
?
D?
Lj
?
utf8mb4
utf8mb4_ja_0900_as_cs_ks
utf8mb4_ja_0900_as_cs
utf8mb4_ja_0900_as_cs
I
U
I
U
J
U
?
o
c
ll
m
ü = Y < ?
xxx
_general_mysql500_cixxx
xxx
_unicode_cixxx
_unicode_ciCHAR_LENGTH()
utf8mb4_unicode_520_ci
utf8mb4_0900_ai_ci
INFORMATION_SCHEMA
COLLATIONS
VARCHAR
'a '
utf8mb4_0900_ai_ci
LOCALE
_0900
_ci
LOWER()
UPPER()
xxx
_general_cixxx
utf8_unicode_ci
?
utf8_unicode_ci
utf8_general_ci
? = A ? = O ü = U
utf8_general_ci
? = s
utf8_unicode_ci
? = ss
utf8
utf8_unicode_ci
utf8_general_ci
s
utf8_general_ci
utf8_german2_ci
? = ? = AE? = ? = OEü = UE? = ss
utf8_german2_ci
?
?
utf8_german_ci
utf8_general_ci
_bin
WEIGHT_STRING()
), weight = code point.xxx
_general_ci
xxx
_unicode_ci
if (code >= 0x3400 && code <= 0x4DB5) base= 0xFB80; /* CJK Ideograph Extension */else if (code >= 0x4E00 && code <= 0x9FA5) base= 0xFB40; /* CJK Ideograph */else base= 0xFBC0; /* All other characters */aaaa= base + (code >> 15);bbbb= (code & 0x7FFF) | 0x8000;
aaaa
mysql> SELECT HEX(WEIGHT_STRING(_ucs2 0x04CF COLLATE ucs2_unicode_ci));
+----------------------------------------------------------+
| HEX(WEIGHT_STRING(_ucs2 0x04CF COLLATE ucs2_unicode_ci)) |
+----------------------------------------------------------+
| FBC084CF |
+----------------------------------------------------------+
U+04cf CYRILLIC SMALL LETTER
PALOCHKA
0xfffd REPLACEMENT
CHARACTER
COUNT(DISTINCT)
创建表的T(S1 varchar(五)字符集utf32整理utf32_unicode_ci);插入T值(0xfffd);/ * * /替换字符插入T值(0x010412);/*该资本信蜂* /插入T值(0x010413);/*该大写字母T恤* /选择计数(不同的S1)T;
xxx
_unicode_ci0xfffd
0xfffd
WEIGHT_STRING()
/ *四个字符的字符串插入are00000041 #大写拉丁字母a0001218f #楔形符号kab000121a7 #楔形符号kish00000042 #拉丁文大写字母B * /创建表(S1 char(4)字符集utf32整理utf32_unicode_ci);插入T值(0x000000410001218f000121a700000042);选择HEX(weight_string(S1))T;
0E33 FFFD FFFD 0E4A
0E33
FFFD
ORDER BY s1 COLLATE utf32_unicode_ci, s1 COLLATE utf32_bin
xxx
_unicode_520_ci
aaaa= base + (code >> 15); bbbb= (code & 0x7FFF) | 0x8000;
utf16_bin
utf16_bin
utf16_bin
E000
Code point Character utf8 utf16 ---------- --------- ---- ----- 0FF9D HALFWIDTH KATAKANA LETTER N EF BE 9D FF 9D 10384 UGARITIC LETTER DELTA F0 90 8E 84 D8 00 DF 84
0xff9d
<utf8
<0xf0
0xff
utf16_bin
utf16
utf16_bin
ucs2
ascii
ascii_bin
ascii_general_ci
cp850
cp850_bin
cp850_general_ci
dec8
dec8_bin
dec8_swedish_ci
hp8
hp8_bin
hp8_english_ci
latin1
latin1_bin
latin1_danish_ci
latin1_general_ci
latin1_general_cs
latin1_german1_ci
latin1_german2_ci
latin1_spanish_ci
latin1_swedish_ci
latin1
cp1252
latin1
0x80
cp1252
0x80
cp1252
0x0081
0x008d
0x008f
0x0090
0x009d
latin1_swedish_ci
latin1_german1_ci
latin1_german1_ci
? = A? = Oü = U? = s
latin1_german2_ci
? = AE? = OEü = UE? = ss
latin1_spanish_ci
n
macroman
macroman_bin
macroman_general_ci
swe7
swe7_bin
swe7_swedish_ci
cp1250
cp1250_bin
cp1250_croatian_ci
cp1250_czech_cs
cp1250_general_ci
cp1250_polish_ci
cp852
cp852_bin
cp852_general_ci
keybcs2
keybcs2_bin
keybcs2_general_ci
latin2
latin2_bin
latin2_croatian_ci
latin2_czech_cs
latin2_general_ci
latin2_hungarian_ci
macce
macce_bin
macce_general_ci
armscii8
armscii8_bin
armscii8_general_ci
cp1256
cp1256_bin
cp1256_general_ci
geostd8
geostd8_bin
geostd8_general_ci
greek
greek_bin
greek_general_ci
hebrew
hebrew_bin
hebrew_general_ci
latin5
latin5_bin
latin5_turkish_ci
cp1257
cp1257_bin
cp1257_general_ci
cp1257_lithuanian_ci
latin7
latin7_bin
latin7_estonian_cs
latin7_general_ci
latin7_general_cs
cp1251
cp1251_bin
cp1251_bulgarian_ci
cp1251_general_ci
cp1251_general_cs
cp1251_ukrainian_ci
cp866
cp866_bin
cp866_general_ci
koi8r
koi8r_bin
koi8r_general_ci
koi8u
koi8u_bin
koi8u_general_ci
cp932
big5
big5_bin
big5_chinese_ci
cp932
cp932_bin
cp932_japanese_ci
eucjpms
eucjpms_bin
eucjpms_japanese_ci
euckr
euckr_bin
euckr_korean_ci
gb2312
gb2312_bin
gb2312_chinese_ci
gbk
gbk_bin
gbk_chinese_ci
gb18030
gb18030_bin
gb18030_chinese_ci
gb18030_unicode_520_ci
sjis
sjis_bin
sjis_japanese_ci
tis620
tis620_bin
tis620_thai_ci
ujis
ujis_bin
ujis_japanese_ci
big5_chinese_ci
cp932
sjis
Shift_JIS
Shift_JIS
cp932
cp932
ucs2
sjis
cp932
Shift_JIS
cp932
cp932
cp932
cp932
cp932
ucs2
cp932
0x87
msdn.microsoft.com HTTPS:/ / / / / gg674964和硕销售额
0xED
https://msdn.microsoft.com/en-us/goglobal/gg671837 https://msdn.microsoft.com/en-us/goglobal/gg671838
0xFA
0xFC
https://msdn.microsoft.com/en-us/goglobal/gg671839 msdn.microsoft.com HTTPS:/ / / / / gg671840和硕销售额 msdn.microsoft.com HTTPS:/ / / / / gg671841和硕销售额
cp932
sjis
ucs2
cp932
ucs2
sjis
| sjis
| cp932
|
---|---|---|
ucs2
ucs2 | ucs2
| ucs2
|
---|---|---|
--character-set-client-handshake
--skip-character-set-client-handshake
gb18030
?
CaseFolding-6.3.0.txt
SET
NAMES
gb18030
gb18030
?
CONVERT()
utf8
gb18030_unicode_520_ci
gb18030_bin
gb18030_chinese_ci
UPPER(ch)
GB+FE39FE39
gb18030_unicode_520_ci
binary
binary
mysql>SET NAMES 'binary';
mysql>SELECT CHARSET('abc'), COLLATION('abc');
+----------------+------------------+ | CHARSET('abc') | COLLATION('abc') | +----------------+------------------+ | binary | binary | +----------------+------------------+ mysql>SELECT 'abc' = 'ABC', 'a' = '?';
+---------------+------------+ | 'abc' = 'ABC' | 'a' = '?' | +---------------+------------+ | 0 | 0 | +---------------+------------+
binary
_bin
BINARYexpr
CAST(expr
AS BINARY) CONVERT(expr
USING BINARY)
expr
_binary 'a'
_binary
lc_messages_dir
lc_messages
mysqld --lc_messages_dir=/usr/share/mysql --lc_messages=fr_FR
fr_FR
/usr/share/mysql/french
share/mysql/
LANGUAGE
lc_messages
lc_messages_dir
lc_messages_dir
lc_messages
lc_messages
SET lc_messages = 'en_US';
greek
big5
MYSET
<charset>
MYSET
latin1
<charset>
<charset name="latin1"> <family>Western</family> <description>cp1252 West European</description> ... <collation name="latin1_swedish_ci" id="8" order="Finnish, Swedish"> <flag>primary</flag> <flag>compiled</flag> </collation> <collation name="latin1_danish_ci" id="15" order="Danish"/> ... <collation name="latin1_bin" id="47" order="Binary"> <flag>binary</flag> <flag>compiled</flag> </collation> ... </charset>
<charset>
primary
SELECT MAX(ID) FROM INFORMATION_SCHEMA.COLLATIONS;
MYSET
.xmllatin1.xml
<!--
text
-->
<map>
<map>
<map>
<ctype>
<map>
<charset>
MYSET
.xml<collation>
ctype-
MYSET
.cctype-*.c
ctype_
MYSET
MYSET
<collation>
<charset>
Index.xml
MYSET
MYSYS
MYSET
mysys/charset-def.c
#ifdef HAVE_CHARSET_MYSET
extern CHARSET_INFO my_charset_MYSET
_general_ci; extern CHARSET_INFO my_charset_MYSET
_bin; #endif
#ifdef HAVE_CHARSET_MYSET
add_compiled_collation(&my_charset_MYSET
_general_ci); add_compiled_collation(&my_charset_MYSET
_bin); #endif
ctype-
MYSET
.cctype-
MYSET
.c
cmake/character_sets.cmake
MYSET
MYSET
-DDEFAULT_CHARSET=
MYSET
sql/share/charsets
MYSYS
MYSET
<map>
<map>
<ctype>
<lower>
<upper>
<unicode>
<collation>
<map>
ctype-
MYSET
.cctype_
MYSET
[]MYSET
CHARSET_INFO.txt
<ctype>
<ctype>
#define _MY_U 01 /* Upper case */ #define _MY_L 02 /* Lower case */ #define _MY_NMR 04 /* Numeral (digit) */ #define _MY_SPC 010 /* Spacing character */ #define _MY_PNT 020 /* Punctuation */ #define _MY_CTR 040 /* Control character */ #define _MY_B 0100 /* Blank */ #define _MY_X 0200 /* heXadecimal digit */
<ctype>
_MY_U
ctype
ctype['A'+1] = _MY_U | _MY_X = 01 | 0200 = 0201
m_ctype.h
<ctype>
MYSET
.xml
<lower>
<upper>
lower['A'] should contain 'a' upper['a'] should contain 'A'
<collation>
<upper>
WEIGHT_STRING()
str
mysql>SELECT HEX(WEIGHT_STRING('AaBb' COLLATE latin1_swedish_ci));
+------------------------------------------------------+ | HEX(WEIGHT_STRING('AaBb' COLLATE latin1_swedish_ci)) | +------------------------------------------------------+ | 41414242 | +------------------------------------------------------+ mysql>SELECT HEX(WEIGHT_STRING(BINARY 'AaBb'));
+-----------------------------------+ | HEX(WEIGHT_STRING(BINARY 'AaBb')) | +-----------------------------------+ | 41614262 | +-----------------------------------+
xxx
_bin
latin1_swedish_ci
MySQL的> SET NAMES 'latin1' COLLATE 'latin1_swedish_ci';
查询好,为受影响的行(0.01秒)MySQL > SELECT HEX(WEIGHT_STRING('a')), HEX(WEIGHT_STRING('A'));
------------------------- ------------------------- | hex(weight_string(A))| hex(weight_string(A))| ------------------------- ------------------------- | 41 | 41 | ------------------------- ------------------------- 1行集(0.01秒)MySQL > SELECT 'a' = 'A';
+-----------+| 'a' = 'A' |+-----------+| 1 |+-----------+1 row in set (0.12 sec)
'a'
0x41
sjis_japanese_ci
0x82C0
mysql>CREATE TABLE t1
(c1 VARCHAR(2) CHARACTER SET sjis COLLATE sjis_japanese_ci);
Query OK, 0 rows affected (0.01 sec) mysql>INSERT INTO t1 VALUES ('a'),('A'),(0x82C0);
Query OK, 3 rows affected (0.00 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql>SELECT c1, HEX(c1), HEX(WEIGHT_STRING(c1)) FROM t1;
+------+---------+------------------------+ | c1 | HEX(c1) | HEX(WEIGHT_STRING(c1)) | +------+---------+------------------------+ | a | 61 | 41 | | A | 41 | 41 | | ぢ | 82C0 | 82C0 | +------+---------+------------------------+ 3 rows in set (0.00 sec)
gbk_chinese_ci
0x81B0
mysql>CREATE TABLE t1
(c1 VARCHAR(2) CHARACTER SET gbk COLLATE gbk_chinese_ci);
Query OK, 0 rows affected (0.33 sec) mysql>INSERT INTO t1 VALUES ('a'),('A'),(0x81B0);
Query OK, 3 rows affected (0.00 sec) Records: 3 Duplicates: 0 Warnings: 0 mysql>SELECT c1, HEX(c1), HEX(WEIGHT_STRING(c1)) FROM t1;
+------+---------+------------------------+ | c1 | HEX(c1) | HEX(WEIGHT_STRING(c1)) | +------+---------+------------------------+ | a | 61 | 41 | | A | 41 | 41 | | 膰 | 81B0 | C286 | +------+---------+------------------------+ 3 rows in set (0.00 sec)
utf8_general_ci
'A'
'á'
mysql>SET NAMES 'utf8' COLLATE 'utf8_general_ci';
Query OK, 0 rows affected (0.00 sec) mysql>CREATE TABLE t1
(c1 CHAR(1) CHARACTER SET UTF8 COLLATE utf8_general_ci);
Query OK, 0 rows affected (0.01 sec) mysql>INSERT INTO t1 VALUES ('a'),('A'),('à'),('á');
Query OK, 4 rows affected (0.00 sec) Records: 4 Duplicates: 0 Warnings: 0 mysql>SELECT c1, HEX(c1), HEX(WEIGHT_STRING(c1)) FROM t1;
+------+---------+------------------------+ | c1 | HEX(c1) | HEX(WEIGHT_STRING(c1)) | +------+---------+------------------------+ | a | 61 | 0041 | | A | 41 | 0041 | | à | C380 | 0041 | | á | C3A1 | 0041 | +------+---------+------------------------+ 4 rows in set (0.00 sec)
'a'
mysql>SET NAMES 'utf8' COLLATE 'utf8_unicode_ci';
Query OK, 0 rows affected (0.05 sec) mysql>SELECT HEX('a'), HEX(WEIGHT_STRING('a'));
+----------+-------------------------+ | HEX('a') | HEX(WEIGHT_STRING('a')) | +----------+-------------------------+ | 61 | 0E33 | +----------+-------------------------+ 1 row in set (0.02 sec)
'?'
mysql>SET NAMES 'utf8' COLLATE 'utf8_unicode_ci';
Query OK, 0 rows affected (0.11 sec) mysql>SELECT HEX('?'), HEX(WEIGHT_STRING('?'));
+-----------+--------------------------+ | HEX('?') | HEX(WEIGHT_STRING('?')) | +-----------+--------------------------+ | C39F | 0FEA0FEA | +-----------+--------------------------+ 1 row in set (0.00 sec)
'ch'
mysql>SET NAMES 'utf8' COLLATE 'utf8_czech_ci';
Query OK, 0 rows affected (0.09 sec) mysql>SELECT HEX('ch'), HEX(WEIGHT_STRING('ch'));
+-----------+--------------------------+ | HEX('ch') | HEX(WEIGHT_STRING('ch')) | +-----------+--------------------------+ | 6368 | 0EE2 | +-----------+--------------------------+ 1 row in set (0.00 sec)
Id
SHOW COLLATION
charsetnr
number
mysql_get_character_set_info()
mysql> SELECT MAX(ID) FROM INFORMATION_SCHEMA.COLLATIONS;
+---------+
| MAX(ID) |
+---------+
| 210 |
+---------+
mysql> SELECT ID FROM INFORMATION_SCHEMA.COLLATIONS ORDER BY ID;
+-----+
| ID |
+-----+
| 1 |
| 2 |
| ... |
| 52 |
| 53 |
| 57 |
| 58 |
| ... |
| 98 |
| 99 |
| 128 |
| 129 |
| ... |
| 210 |
+-----+
<collation>
<charset>
Index.xml
latin1
Index.xml
character_sets_dir
MySQL的> SHOW VARIABLES LIKE 'character_sets_dir';
| -------------------- ----------------------------------------- _ name值变| | -------------------- ----------------------------------------- |字符集_ _ | /用户/地方/目录/分享/ MySQL / MySQL / | charsets ----------------------------------------- --------------------
Index.xml
<charset>
<collation>
<charset name="latin1"> ... <collation name="latin1_test_ci" id="1024"/> ...</charset>
latin1.xml
<collation>
<map>
<map>
<collation name="latin1_test_ci"> <map> 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 7B 7C 7D 7E 7F 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF 41 41 41 41 5B 5D 5B 43 45 45 45 45 49 49 49 49 44 4E 4F 4F 4F 4F 5C D7 5C 55 55 55 59 59 DE DF 41 41 41 41 5B 5D 5B 43 45 45 45 45 49 49 49 49 44 4E 4F 4F 4F 4F 5C F7 5C 55 55 55 59 59 DE FF </map> </collation>
mysql> SHOW COLLATION WHERE Collation = 'latin1_test_ci';
+----------------+---------+------+---------+----------+---------+
| Collation | Charset | Id | Default | Compiled | Sortlen |
+----------------+---------+------+---------+----------+---------+
| latin1_test_ci | latin1 | 1024 | | | 1 |
+----------------+---------+------+---------+----------+---------+
<collation>
<charset>
Index.xml
utf16le
utf8 | utf8_unicode_ci |
---|---|
ucs2 | ucs2_unicode_ci |
utf16 | utf16_unicode_ci |
utf32 | utf32_unicode_ci |
utf8_phone_ci
+7-12345-67 +7-12-345-67 +7 12 345 67 +7 (12) 345 67 +71234567
Index.xml
character_sets_dir
MySQL的> SHOW VARIABLES LIKE 'character_sets_dir';
| -------------------- ----------------------------------------- _ name值变| | -------------------- ----------------------------------------- |字符集_ _ | /用户/地方/目录/分享/ MySQL / MySQL / | charsets ----------------------------------------- --------------------
Index.xml
<charset>
<collation>
<collation>
<rules>
<charset name="utf8"> ... <collation name="utf8_phone_ci" id="1029"> <rules> <reset>\u0000</reset> <i>\u0020</i> <!-- space --> <i>\u0028</i> <!-- left parenthesis --> <i>\u0029</i> <!-- right parenthesis --> <i>\u002B</i> <!-- plus --> <i>\u002D</i> <!-- hyphen --> </rules> </collation> ...</charset>
<collation>
<collation>
<charset name="ucs2">
mysql> SHOW COLLATION WHERE Collation = 'utf8_phone_ci';
+---------------+---------+------+---------+----------+---------+
| Collation | Charset | Id | Default | Compiled | Sortlen |
+---------------+---------+------+---------+----------+---------+
| utf8_phone_ci | utf8 | 1029 | | | 8 |
+---------------+---------+------+---------+----------+---------+
mysql>CREATE TABLE phonebook (
name VARCHAR(64),
phone VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_phone_ci
);
Query OK, 0 rows affected (0.09 sec) mysql>INSERT INTO phonebook VALUES ('Svoj','+7 912 800 80 02');
Query OK, 1 row affected (0.00 sec) mysql>INSERT INTO phonebook VALUES ('Hf','+7 (912) 800 80 04');
Query OK, 1 row affected (0.00 sec) mysql>INSERT INTO phonebook VALUES ('Bar','+7-912-800-80-01');
Query OK, 1 row affected (0.00 sec) mysql>INSERT INTO phonebook VALUES ('Ramil','(7912) 800 80 03');
Query OK, 1 row affected (0.00 sec) mysql>INSERT INTO phonebook VALUES ('Sanja','+380 (912) 8008005');
Query OK, 1 row affected (0.00 sec)
mysql>SELECT * FROM phonebook ORDER BY phone;
+-------+--------------------+ | name | phone | +-------+--------------------+ | Sanja | +380 (912) 8008005 | | Bar | +7-912-800-80-01 | | Svoj | +7 912 800 80 02 | | Ramil | (7912) 800 80 03 | | Hf | +7 (912) 800 80 04 | +-------+--------------------+ 5 rows in set (0.00 sec) mysql>SELECT * FROM phonebook WHERE phone='+7(912)800-80-01';
+------+------------------+ | name | phone | +------+------------------+ | Bar | +7-912-800-80-01 | +------+------------------+ 1 row in set (0.00 sec) mysql>SELECT * FROM phonebook WHERE phone='79128008001';
+------+------------------+ | name | phone | +------+------------------+ | Bar | +7-912-800-80-01 | +------+------------------+ 1 row in set (0.00 sec) mysql>SELECT * FROM phonebook WHERE phone='7 9 1 2 8 0 0 8 0 0 1';
+------+------------------+ | name | phone | +------+------------------+ | Bar | +7-912-800-80-01 | +------+------------------+ 1 row in set (0.00 sec)
<rules>
</rules>
Index.xml
Index.xml
\u
nnnn
nnnn
á
\u00E1
F
\u00e1
FFFF
Index.xml
<reset>
'A'
<reset>A</reset><reset>\u0041</reset>
<p>
<s>
<t>
'G'
<p>G</p><p>\u0047</p>
<i>
'a'
<reset>a</reset><i>b</i>
<pc>xyz</pc> | <p>x</p><p>y</p><p>z</p> |
<sc>xyz</sc> | <s>x</s><s>y</s><s>z</s> |
<tc>xyz</tc> | <t>x</t><t>y</t><t>z</t> |
<ic>xyz</ic> | <i>x</i><i>y</i><i>z</i> |
'z'
<reset>abc</reset> <p>z</p>
'xyz'
<reset>a</reset> <p>xyz</p>
'xyz'
<reset>abc</reset> <p>xyz</p>
<x>
<extend>
'k'
'k'
'h'
<reset>c</reset><x><s>k</s><extend>h</extend></x>
'ccs'
<reset>cs</reset> <x><t>ccs</t><extend>cs</extend></x>
<x>
<context>
'-'
'-'
<reset>a</reset> <x><context>b</context><s>-</s></x>
<extend>
'aghi'
'abc'
<reset>a</reset><x><context>abc</context><p>def</p><extend>ghi</extend></x>
before
'b'
<reset before="primary">a</reset> <p>b</p>
before
<reset before="primary"><reset before="1"><reset before="secondary"><reset before="2"><reset before="tertiary"><reset before="3">
<first_tertiary_ignorable/> <last_tertiary_ignorable/> <first_secondary_ignorable/> <last_secondary_ignorable/> <first_primary_ignorable/> <last_primary_ignorable/> <first_variable/> <last_variable/> <first_non_ignorable/> <last_non_ignorable/> <first_trailing/> <last_trailing/>
'z'
<reset><last_non_ignorable/></reset><p>z</p>
<first_non_ignorable/> | ||
<last_non_ignorable/> | ||
<first_primary_ignorable/> | ||
<last_primary_ignorable/> | ||
<first_secondary_ignorable/> | ||
<last_secondary_ignorable/> | ||
<first_tertiary_ignorable/> | ||
<last_tertiary_ignorable/> | ||
<first_trailing/> | ||
<last_trailing/> | ||
<first_variable/> | ||
<last_variable/> |
<collation>
simple
expand
'0'
0E29
'0'
<reset>0</reset> <pc>abcdefghijklmnopqrstuvwxyz</pc>
'a' has weight 0E29+1 'b' has weight 0E29+2 'c' has weight 0E29+3 ...
'0'
shift-after-method="expand"
一个有重量0e29 ] [ 1 ] [ 233d B具有重量0e29 ] [ 2 ] [ 233d C具有重量0e29 ] [ 3 ] [ 233d…
233D
3ACA
<collation>
<collation>
4.0.0
<collation id="nnn
" name="utf8_xxx
_ci" version="5.2.0">...</collation>
Index.xml
<aaa>
[ Warning ] Buffered Warning:unknown LDML tag : ' Charsets / Charse / Collation / Rules / AAA '
SHOW
WARNINGS
<reset>abcdefghi</reset><i>x</i>
mysql>SELECT _utf8'test' COLLATE utf8_test_ci;
ERROR 1273 (HY000): Unknown collation: 'utf8_test_ci' mysql>SHOW WARNINGS;
+---------+------+----------------------------------------+ | Level | Code | Message | +---------+------+----------------------------------------+ | Error | 1273 | Unknown collation: 'utf8_test_ci' | | Warning | 1273 | Expansion is too long at 'abcdefghi=x' | +---------+------+----------------------------------------+
--character-set-server
--collation-server
SHOW
COLLATION
share/mysql/charsets
--character-sets-dir
[client] character-sets-dir=/usr/local/mysql/share/mysql/charsets [client] character-sets-dir="C:/Program Files/MySQL/MySQL Server 8.0/share/charsets"
Index.xml
字符集” charset_name
“不是一个编译字符集和没有指定在“/ usr /分享/ MySQL /字符集/索引XML文件。
[client]
default-character-set=charset_name
character_set_system
character_set_server
character_set_client
--default-character-set=
system_character_set
MyISAM
tbl_name
lc_time_names
DATE_FORMAT()
DAYNAME()
MONTHNAME()
lc_time_names
STR_TO_DATE()
GET_FORMAT()
lc_time_names
FORMAT()
lc_time_names
'ja_JP'
'en_US'
SYSTEM_VARIABLES_ADMIN
SUPER
lc_time_names
mysql>SET NAMES 'utf8';
Query OK, 0 rows affected (0.09 sec) mysql>SELECT @@lc_time_names;
+-----------------+ | @@lc_time_names | +-----------------+ | en_US | +-----------------+ 1 row in set (0.00 sec) mysql>SELECT DAYNAME('2010-01-01'), MONTHNAME('2010-01-01');
+-----------------------+-------------------------+ | DAYNAME('2010-01-01') | MONTHNAME('2010-01-01') | +-----------------------+-------------------------+ | Friday | January | +-----------------------+-------------------------+ 1 row in set (0.00 sec) mysql>SELECT DATE_FORMAT('2010-01-01','%W %a %M %b');
+-----------------------------------------+ | DATE_FORMAT('2010-01-01','%W %a %M %b') | +-----------------------------------------+ | Friday Fri January Jan | +-----------------------------------------+ 1 row in set (0.00 sec) mysql>SET lc_time_names = 'es_MX';
Query OK, 0 rows affected (0.00 sec) mysql>SELECT @@lc_time_names;
+-----------------+ | @@lc_time_names | +-----------------+ | es_MX | +-----------------+ 1 row in set (0.00 sec) mysql>SELECT DAYNAME('2010-01-01'), MONTHNAME('2010-01-01');
+-----------------------+-------------------------+ | DAYNAME('2010-01-01') | MONTHNAME('2010-01-01') | +-----------------------+-------------------------+ | viernes | enero | +-----------------------+-------------------------+ 1 row in set (0.00 sec) mysql>SELECT DATE_FORMAT('2010-01-01','%W %a %M %b');
+-----------------------------------------+ | DATE_FORMAT('2010-01-01','%W %a %M %b') | +-----------------------------------------+ | viernes vie enero ene | +-----------------------------------------+ 1 row in set (0.00 sec)
utf8
character_set_connection
lc_time_names
ar_AE | ar_BH |
ar_DZ | ar_EG |
ar_IN | ar_IQ |
ar_JO | ar_KW |
ar_LB | ar_LY |
ar_MA | ar_OM |
ar_QA | ar_SA |
ar_SD | ar_SY |
ar_TN | ar_YE |
be_BY | bg_BG |
ca_ES | cs_CZ |
da_DK | de_AT |
de_BE | de_CH |
de_DE | de_LU |
el_GR | en_AU |
en_CA | en_GB |
en_IN | en_NZ |
en_PH | en_US |
en_ZA | en_ZW |
es_AR | es_BO |
es_CL | es_CO |
es_CR | es_DO |
es_EC | es_ES |
es_GT | es_HN |
es_MX | es_NI |
es_PA | es_PE |
es_PR | es_PY |
es_SV | es_US |
es_UY | es_VE |
et_EE | eu_ES |
fi_FI | fo_FO |
fr_BE | fr_CA |
fr_CH | fr_FR |
fr_LU | gl_ES |
gu_IN | he_IL |
hi_IN | hr_HR |
hu_HU | id_ID |
is_IS | it_CH |
it_IT | ja_JP |
ko_KR | lt_LT |
lv_LV | mk_MK |
mn_MN | ms_MY |
nb_NO | nl_BE |
nl_NL | no_NO |
pl_PL | pt_BR |
pt_PT | rm_CH |
ro_RO | ru_RU |
ru_UA | sk_SK |
sl_SI | sq_AL |
sr_RS | sv_FI |
sv_SE | ta_IN |
te_IN | th_TH |
tr_TR | uk_UA |
ur_PK | vi_VN |
zh_CN | zh_HK |
zh_TW |