Loading...
MySQL 9.5 Reference Manual 9.5의 22.4.5 Documents in Tables의 한국어 번역본입니다.
아래의 경우에 피드백에서 신고해주신다면 반영하겠습니다.
감사합니다 :)
MySQL에서 하나의 table은 전통적인 관계형 데이터, JSON 값, 또는 둘 다를 포함할 수 있습니다. native JSON 데이터 타입을 갖는 column에 document를 저장함으로써, 전통적인 데이터와 JSON document를 결합할 수 있습니다.
이 절의 예제에서는 world_x schema의 city table을 사용합니다.
city table에는 다섯 개의 column(또는 field)이 있습니다.
+---------------+------------+-------+-------+---------+------------------+ | Field | Type | Null | Key | Default | Extra | +---------------+------------+-------+-------+---------+------------------+ | ID | int(11) | NO | PRI | null | auto_increment | | Name | char(35) | NO | | | | | CountryCode | char(3) | NO | | | | | District | char(20) | NO | | | | | Info | json | YES | | null | | +---------------+------------+-------+-------+---------+------------------+
table의 column에 document를 삽입하려면, values() method에 올바른 순서의 제대로 구성된 JSON document를 전달합니다. 다음 예제에서, document는 Info column에 삽입될 마지막 값으로 전달됩니다.
1mysql-py> db.city.insert().values( 2None, "San Francisco", "USA", "California", '{"Population":830000}')
expression에서 document 값들을 평가하는 search condition을 사용하여 query를 실행할 수 있습니다.
1mysql-py> db.city.select(["ID", "Name", "CountryCode", "District", "Info"]).where( 2"CountryCode = :country and Info->'$.Population' > 1000000").bind( 3'country', 'USA') 4+------+----------------+-------------+----------------+-----------------------------+ 5| ID | Name | CountryCode | District | Info | 6+------+----------------+-------------+----------------+-----------------------------+ 7| 3793 | New York | USA | New York | {"Population": 8008278} | 8| 3794 | Los Angeles | USA | California | {"Population": 3694820} | 9| 3795 | Chicago | USA | Illinois | {"Population": 2896016} | 10| 3796 | Houston | USA | Texas | {"Population": 1953631} | 11| 3797 | Philadelphia | USA | Pennsylvania | {"Population": 1517550} | 12| 3798 | Phoenix | USA | Arizona | {"Population": 1321045} | 13| 3799 | San Diego | USA | California | {"Population": 1223400} | 14| 3800 | Dallas | USA | Texas | {"Population": 1188580} | 15| 3801 | San Antonio | USA | Texas | {"Population": 1144646} | 16+------+----------------+-------------+----------------+-----------------------------+ 179 rows in set (0.01 sec)
자세한 내용은
Working with Relational Tables and Documents
을(를) 참조하십시오.
데이터 타입에 대한 자세한 설명은
Section 13.5, “The JSON Data Type”을(를) 참조하십시오.
22.4.4 Relational Tables
22.5 X Plugin