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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.5k
Designing for humans not robots
tammielis
254
26k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Practical Orchestrator
shlominoach
192
12k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
330
It's Worth the Effort
3n
188
29k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
Designing for Performance
lara
612
70k
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 を設定しましょう
ありがとうございました