단일 셀에 요소 집합을 추가하려면 JSON 개념을 사용합니다. 먼저 테이블을 생성하겠습니다 -
mysql> create table DemoTable1828 ( EmployeeId int, EmployeeRecords JSON ); Query OK, 0 rows affected (0.00 sec)
삽입 명령을 사용하여 테이블에 일부 레코드 삽입 -
mysql> insert into DemoTable1828 values(1,'[{"EmployeeName":"Chris","EmployeeAge":29},{"EmployeeName":"David","EmployeeAge":27}]'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1828 values(2,'[{"EmployeeName":"John","EmployeeAge":36},{"EmployeeName":"Mike","EmployeeAge":32}]'); Query OK, 1 row affected (0.00 sec)
select 문을 사용하여 테이블의 모든 레코드 표시 -
mysql> select * from DemoTable1828;
이것은 다음과 같은 출력을 생성합니다 -
+------------+----------------------------------------------------------------------------------------------+ | EmployeeId | EmployeeRecords | +------------+----------------------------------------------------------------------------------------------+ | 1 | [{"EmployeeAge": 29, "EmployeeName": "Chris"}, {"EmployeeAge": 27, "EmployeeName": "David"}] | | 2 | [{"EmployeeAge": 36, "EmployeeName": "John"}, {"EmployeeAge": 32, "EmployeeName": "Mike"}] | +------------+----------------------------------------------------------------------------------------------+ 2 rows in set (0.00 sec)