feat(sql): utf-8
parent
99fbb2afb3
commit
6bdbcb9c81
|
@ -144,6 +144,23 @@
|
|||
>
|
||||
</li>
|
||||
</ul>
|
||||
<h2 id="user-content-be-careful-with-utf-8">
|
||||
<a class="heading-link" href="#be-careful-with-utf-8"
|
||||
>Be careful with UTF-8<span
|
||||
aria-hidden="true"
|
||||
class="octicon octicon-link"
|
||||
></span
|
||||
></a>
|
||||
</h2>
|
||||
<p>TLDR with MySQL:</p>
|
||||
<div class="highlight highlight-source-sql">
|
||||
<pre><span class="pl-k">CREATE</span> <span class="pl-k">TABLE</span> <span class="pl-en">ekyc_approved</span>
|
||||
(
|
||||
id <span class="pl-k">varchar</span>(<span class="pl-c1">30</span>) <span class="pl-k">NOT NULL</span>,
|
||||
<span class="pl-k">PRIMARY KEY</span> (id),
|
||||
) ENGINE <span class="pl-k">=</span> InnoDB
|
||||
DEFAULT CHARSET <span class="pl-k">=</span> utf8mb4;</pre>
|
||||
</div>
|
||||
<h2 id="user-content-be-careful-with-null">
|
||||
<a class="heading-link" href="#be-careful-with-null"
|
||||
>Be careful with NULL<span
|
||||
|
|
|
@ -70,6 +70,19 @@ Use `EXPLAIN` to check if index is used or not:
|
|||
- [For MySQL 5.7](https://dev.mysql.com/doc/refman/5.7/en/explain-output.html)
|
||||
- [For MySQL 8.0](https://dev.mysql.com/doc/refman/8.0/en/explain-output.html)
|
||||
|
||||
## Be careful with UTF-8
|
||||
|
||||
TLDR with MySQL:
|
||||
|
||||
```sql
|
||||
CREATE TABLE ekyc_approved
|
||||
(
|
||||
id varchar(30) NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4;
|
||||
```
|
||||
|
||||
## Be careful with NULL
|
||||
|
||||
If compare with field which can be NULL, remember to check NULL for safety.
|
||||
|
|
Loading…
Reference in New Issue