mysql json

main
sudo pacman -Syu 2024-10-31 01:59:03 +07:00
parent 1a8569d0ec
commit 48eec1a42b
2 changed files with 36 additions and 16 deletions

View File

@ -124,24 +124,42 @@
<p>JSON data type is also useful for dumping request, response data.</p>
<ul>
<li>
<a
href="https://dev.mysql.com/doc/refman/5.7/en/json.html"
rel="nofollow"
>For MySQL 5.7</a
>
<p>
Use <code>JSON_CONTAINS_PATH(col, 'one', '$.key')</code> to check json
field exist or not
</p>
</li>
<li>
<a
href="https://dev.mysql.com/doc/refman/8.0/en/json.html"
rel="nofollow"
>For MySQL 8.0</a
>
<p>Use <code>col-&gt;'$.key'</code> to get value</p>
</li>
<li>
<p>
<a
href="https://dev.mysql.com/doc/refman/5.7/en/json.html"
rel="nofollow"
>For MySQL 5.7</a
>
</p>
</li>
<li>
<p>
<a
href="https://dev.mysql.com/doc/refman/8.0/en/json.html"
rel="nofollow"
>For MySQL 8.0</a
>
</p>
</li>
<li>
<p>
<a
href="https://planetscale.com/blog/indexing-json-in-mysql"
rel="nofollow"
>Indexing JSON in MySQL</a
>
</p>
</li>
</ul>
<p>
Use <code>JSON_EXTRACT(col, '$.key') IS NULL</code> to check json field
exist or not.
</p>
<div class="markdown-heading">
<h2 class="heading-element">Use index!!!</h2>
<a

View File

@ -40,10 +40,12 @@ I always use MySQL json data type for extra field.
JSON data type is also useful for dumping request, response data.
- Use `JSON_CONTAINS_PATH(col, 'one', '$.key')` to check json field exist or not
- Use `col->'$.key'` to get value
- [For MySQL 5.7](https://dev.mysql.com/doc/refman/5.7/en/json.html)
- [For MySQL 8.0](https://dev.mysql.com/doc/refman/8.0/en/json.html)
Use `JSON_EXTRACT(col, '$.key') IS NULL` to check json field exist or not.
- [Indexing JSON in MySQL](https://planetscale.com/blog/indexing-json-in-mysql)
## Use index!!!