# MySQL/MariaDB資料庫的JSON操作 ###### tags: `資料庫`, `MySQL`, `MariaDB`, `JSON` 2021/10/05 參考資料 https://mariadb.com/resources/blog/json-with-mariadb-10-2/ https://www.itread01.com/content/1544804299.html MariaDB 10.2 起支持 JSON MySQL 5.7 起支持 JSON 共同支援 語法|說明 --|-- SELECT JSON_VALID(jsonStr)|判斷jsonStr是否是合法的json SELECT JSON_VALUE(jsonStr, '$.colour')| 讀取json中colour欄位 SELECT JSON_REPLACE(jsonStr, '$.colour', 'red')|替換json中colour欄位的內容 僅MySQL 語法|說明 --|-- JSON_UNQUOTE(modify->'$.teachername')|讀取modify欄位的json中的teachername欄位 MySQL 也有專門的函式 JSON_OBJECT,JSON_ARRAY 生成 json 格式的資料 JSON_INSERT() 插入新值,但不會覆蓋已經存在的值 JSON_SET() 插入新值,並覆蓋已經存在的值 JSON_REPLACE() 只替換存在的值 JSON_REMOVE() 刪除 JSON 元素
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up