Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
MySQLと文字コードの話
Search
nombom7
January 22, 2020
140
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
MySQLと文字コードの話
nombom7
January 22, 2020
Featured
See All Featured
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
270
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
KATA
mclloyd
PRO
35
15k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
520
Accessibility Awareness
sabderemane
1
210
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
190
Making the Leap to Tech Lead
cromwellryan
135
10k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
42k
Transcript
MySQLと文字コードの話 ぼんばー
自己紹介
ASP.NET(VB.NET)データベース ぼんばー Skill 工場向け生産制御システム開発会社(2017/04~) Work 28 Age 本名 自己紹介 @nom_bom
野村 晃聖
Laravelなんもわからん (DBならなんとか。。。)
という訳で DBの話をします
事前調査
Laravel MySQL Laravel Postgres 日本 世界 直近1年間のGoogle検索数の推移
Twitterのアンケート
という訳で MySQLの話をします
MySQLの文字コード
MySQLには2種類の設定項目がある ・charset ・collation 文字コード 照合順序
charset
文字集合 エンコーディング
文字集合 エンコーディング 規格 実装(符号化) charset JIS X 0208 JIS X
0201 US-ASCII Shift-JIS EUC-JP Windows-31J sjis ujis cp938 複数の文字集合を組み合わせ MySQLの世界
ごちゃごちゃしとる
救世主 Unicode
Unicode 文字集合 エンコーディング UTF-8 UTF-16 規格 実装(符号化) … あまり使われない 文字集合の組み合わせ不要
UTF-32
Unicode(UTF-8)一択 色々あるけど ですよね?
でも
charset MySQLにはUTF-8のcharsetが2種類ある utf8 utf8mb4 1文字1~3バイト 1文字1~4バイト こっちが 常識!
utf8mb4にしましょう 特に理由がなければ charset 絵文字も使えます
collation
collation どの文字を等しいとするか? ・大文字/小文字 ・濁音/半濁音/カナ ・絵文字 A:a は:ば:ぱ:ハ:バ:パ : ・拗音 や:ゃ
コレーション;照合順序
utf8mb4_unicode_ci charset 照合規則 _ci _cs Case Sensitive Case Insensitive 大文字/小文字を区別する
大文字/小文字を区別しない collation 例)
照合規則 A:a : は:ば:ハ や:ゃ general_ci = = ≠ ≠
bin ≠ ≠ ≠ ≠ unicode_ci = = = = unicode_520_ci = ≠ = = 引用元:Qiita記事「寿司ビール問題① 初心者→中級者へのSTEP20/25」
Laravelの話
./config/database.php の初期値
None
collation A:a : は:ば:ハ や:ゃ general_ci = = ≠ ≠
bin ≠ ≠ ≠ ≠ unicode_ci = = = = unicode_520_ci = ≠ = = これ
設定方法
'collation' => 'utf8mb4_bin', $table->collation = 'utf8mb4_bin’; $table-> string('columnName’)-> Collate(‘utf8mb4_bin’); ①
② ③ ./config/database.php ./database/migrations/[ファイル名].php DB TABLE カラム
目的に応じて適切な charset collation を設定しましょう
ありがとうございました