테스트 사이트 - 개발 중인 베타 버전입니다

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

· 4년 전 · 1809

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

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

소개드립니다.

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

활용 예1)

[code]

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;

[/code]

 

활용 예2)

[code]

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 |
+------------------------------------------------------------------------------+-------+

[/code]

 

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

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

게시글 목록

번호 제목
17043
17042
17025
17015
17001
16998
16994
16988
16985
16983
16981
16979
16978
16976
16968
16967
16957
16956
16955
16951
16950
16949
16932
16930
16913
16909
16906
16905
16904
16894