[mariadb] 10.6 버전에 추가된 json_table 함수 > 개발자팁

개발자팁

개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.

[mariadb] 10.6 버전에 추가된 json_table 함수 정보

기타 [mariadb] 10.6 버전에 추가된 json_table 함수

본문

10.6 버전에 새로 추가된 함수 같습니다.

개발할때 유용하게 사용할것 같아서

소개드립니다.

아시는분들은 아시겠지만 모르시는 분들을 위해서  정보 공유합니다.

활용 예1)



set @json='
[
  {"name":"Laptop", "color":"black", "price":"1000"},
  {"name":"Jeans",  "color":"blue"}
]';

select * from json_table(@json, '$[*]' 
  columns(
   name  varchar(10) path '$.name', 
   color varchar(10) path '$.color',
   price decimal(8,2) path '$.price' ) 
) as jt;

 

활용 예2)



SELECT * FROM data_table t1, JSON_TABLE(
  t1.words, '$.123456.*' COLUMNS (word TEXT PATH '$')
) AS jt;

+------------------------------------------------------------------------------+-------+
| words                                                                        | word  |
+------------------------------------------------------------------------------+-------+
| {"123456":{"first":"hello","second":"there"}, "78910":{"first":"All good?"}} | hello |
| {"123456":{"first":"hello","second":"there"}, "78910":{"first":"All good?"}} | there |
+------------------------------------------------------------------------------+-------+

 

참고링크 : https://mariadb.com/kb/en/json_table/

추천
3
  • 복사

댓글 0개

© SIRSOFT
현재 페이지 제일 처음으로