Created
September 11, 2013 03:06
-
-
Save yusukeaiko/6518890 to your computer and use it in GitHub Desktop.
MySQLの照合順序 ref: http://qiita.com/Vit-Symty/items/159c27d7d62c78ee9ce7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drop table if exists `utf8_bin`; | |
create table `utf8_bin` | |
( `id` int(11) NOT NULL auto_increment, | |
`str` varchar(255), | |
`num` int(11), | |
primary key (`id`) | |
) | |
engine=InnoDB | |
default character set utf8 collate utf8_bin | |
; | |
drop table if exists `utf8_general_ci`; | |
create table `utf8_general_ci` | |
( `id` int(11) NOT NULL auto_increment, | |
`str` varchar(255), | |
`num` int(11), | |
primary key (`id`) | |
) | |
engine=InnoDB | |
default character set utf8 collate utf8_general_ci | |
; | |
drop table if exists `utf8_unicode_ci`; | |
create table `utf8_unicode_ci` | |
( `id` int(11) NOT NULL auto_increment, | |
`str` varchar(255), | |
`num` int(11), | |
primary key (`id`) | |
) | |
engine=InnoDB | |
default character set utf8 collate utf8_unicode_ci | |
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select '## str = a(半角)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` = 'a' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` = 'a' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` = 'a' | |
; | |
show warnings; | |
select '## str = A(半角)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` = 'A' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` = 'A' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` = 'A' | |
; | |
show warnings; | |
select '## str = a(全角)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` = 'a' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` = 'a' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` = 'a' | |
; | |
show warnings; | |
select '## str = A(全角)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` = 'A' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` = 'A' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` = 'A' | |
; | |
show warnings; | |
select '## str = あ(大文字)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` = 'あ' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` = 'あ' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` = 'あ' | |
; | |
show warnings; | |
select '## str = ぁ(小文字)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` = 'ぁ' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` = 'ぁ' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` = 'ぁ' | |
; | |
show warnings; | |
select '## str = ア(大文字)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` = 'ア' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` = 'ア' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` = 'ア' | |
; | |
show warnings; | |
select '## str = ァ(小文字)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` = 'ァ' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` = 'ァ' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` = 'ァ' | |
; | |
show warnings; | |
select '## str = 高橋' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` = '高橋' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` = '高橋' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` = '高橋' | |
; | |
show warnings; | |
select '## str = 髙橋' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` = '髙橋' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` = '髙橋' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` = '髙橋' | |
; | |
show warnings; | |
select '## str = -(半角)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` = '-' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` = '-' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` = '-' | |
; | |
show warnings; | |
select '## str = −(全角)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` = '−' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` = '−' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` = '−' | |
; | |
show warnings; | |
select '## str = +(半角)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` = '+' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` = '+' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` = '+' | |
; | |
show warnings; | |
select '## str = +(全角)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` = '+' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` = '+' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` = '+' | |
; | |
show warnings; | |
select '## str = 0(半角)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` = '0' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` = '0' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` = '0' | |
; | |
show warnings; | |
select '## str = 0(全角)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` = '0' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` = '0' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` = '0' | |
; | |
show warnings; | |
select '## str = 1(半角)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` = '1' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` = '1' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` = '1' | |
; | |
show warnings; | |
select '## str = 1(全角)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` = '1' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` = '1' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` = '1' | |
; | |
show warnings; | |
select '## str like \'高%\'' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` like '高%' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` like '高%' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` like '高%' | |
; | |
show warnings; | |
select '## str like \'髙%\'' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `str` from `utf8_bin` where `str` like '髙%' | |
union select 'utf8_general_ci' as 'table', `id`, `str` from `utf8_general_ci` where `str` like '髙%' | |
union select 'utf8_unicode_ci' as 'table', `id`, `str` from `utf8_unicode_ci` where `str` like '髙%' | |
; | |
show warnings; | |
select '## num = 0' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `num` from `utf8_bin` where `num` = 0 | |
union select 'utf8_general_ci' as 'table', `id`, `num` from `utf8_general_ci` where `num` = 0 | |
union select 'utf8_unicode_ci' as 'table', `id`, `num` from `utf8_unicode_ci` where `num` = 0 | |
; | |
show warnings; | |
select '## num = a(半角)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `num` from `utf8_bin` where `num` = 'a' | |
union select 'utf8_general_ci' as 'table', `id`, `num` from `utf8_general_ci` where `num` = 'a' | |
union select 'utf8_unicode_ci' as 'table', `id`, `num` from `utf8_unicode_ci` where `num` = 'a' | |
; | |
show warnings; | |
select '## num = A(半角)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `num` from `utf8_bin` where `num` = 'A' | |
union select 'utf8_general_ci' as 'table', `id`, `num` from `utf8_general_ci` where `num` = 'A' | |
union select 'utf8_unicode_ci' as 'table', `id`, `num` from `utf8_unicode_ci` where `num` = 'A' | |
; | |
show warnings; | |
select '## num = AAA(半角)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `num` from `utf8_bin` where `num` = 'AAA' | |
union select 'utf8_general_ci' as 'table', `id`, `num` from `utf8_general_ci` where `num` = 'AAA' | |
union select 'utf8_unicode_ci' as 'table', `id`, `num` from `utf8_unicode_ci` where `num` = 'AAA' | |
; | |
show warnings; | |
select '## num = a(全角)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `num` from `utf8_bin` where `num` = 'a' | |
union select 'utf8_general_ci' as 'table', `id`, `num` from `utf8_general_ci` where `num` = 'a' | |
union select 'utf8_unicode_ci' as 'table', `id`, `num` from `utf8_unicode_ci` where `num` = 'a' | |
; | |
show warnings; | |
select '## num = A(全角)' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `num` from `utf8_bin` where `num` = 'A' | |
union select 'utf8_general_ci' as 'table', `id`, `num` from `utf8_general_ci` where `num` = 'A' | |
union select 'utf8_unicode_ci' as 'table', `id`, `num` from `utf8_unicode_ci` where `num` = 'A' | |
; | |
show warnings; | |
select '## num like \'1%\'' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `num` from `utf8_bin` where `num` like '1%' | |
union select 'utf8_general_ci' as 'table', `id`, `num` from `utf8_general_ci` where `num` like '1%' | |
union select 'utf8_unicode_ci' as 'table', `id`, `num` from `utf8_unicode_ci` where `num` like '1%' | |
; | |
show warnings; | |
select '## num like \'a%\'' as '実行内容'; | |
select 'utf8_bin' as 'table', `id`, `num` from `utf8_bin` where `num` like 'a%' | |
union select 'utf8_general_ci' as 'table', `id`, `num` from `utf8_general_ci` where `num` like 'a%' | |
union select 'utf8_unicode_ci' as 'table', `id`, `num` from `utf8_unicode_ci` where `num` like 'a%' | |
; | |
show warnings; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
insert into `utf8_bin`(`str`, `num`) | |
values | |
('a', null), | |
('a', null), | |
('A', null), | |
('A', null), | |
('あ', null), | |
('ぁ', null), | |
('ア', null), | |
('ァ', null), | |
('高橋', null), | |
('髙橋', null), | |
('-', null), | |
('−', null), | |
('+', null), | |
('+', null), | |
('0', null), | |
('0', null), | |
('1', null), | |
('1', null), | |
(null, 0), | |
(null, 1), | |
(null, 9), | |
(null, 100) | |
; | |
insert into `utf8_general_ci`(`str`, `num`) select `str`, `num` from `utf8_bin`; | |
insert into `utf8_unicode_ci`(`str`, `num`) select `str`, `num` from `utf8_bin`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment