Database/MySQL
-
[MySQL] foreign_key_checks 알아보기Database/MySQL 2024. 3. 26. 07:29
- 목차 들어가며. 이번 글에서는 MySQL 의 테이블 간 외래키 제약 (Foreign Key Constraints) 을 On/Off 할 수 있는 설정인 foreign_key_checks 에 대해서 알아보려고 합니다. On and Off foreign_key_checks. MySQL 실행하기. 먼저 실습을 위해서 도커를 활용한 MySQL 서버를 실행시켜보겠습니다. docker run -d --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=1234 mysql:8.0.23 그리고 Foreign Key 관계의 테이블 2개를 생성해보겠습니다. docker exec -it mysql mysql -uroot -p1234 create database test; use test; ..
-
[MySQL] group_concat 함수 알아보기Database/MySQL 2024. 3. 8. 21:54
- 목차 group_concat ?group_concat 함수는 MySQL 의 집계함수 중의 하나입니다.집계함수란 Group By 문장과 함께 쓰여져 나열되는 값들을 하나의 값으로 축소시키는 역할을 합니다.예를 들어서 List -> Item, Vector -> Scalar 와 같은 형식으로 Collection 타입의 값을 Single Item 값으로 변형할 수 있습니다.대표적으로 Max, Sum, Avg, Reduce 등이 존재하죠.Collection 의 여러 값들 중에서 최대, 최소, 평균, 합계 등을 계산하여 하나의 값으로 축소시킵니다. group_concat 은 이러한 Aggregation Function 으로 사용됩니다.동작 방식은 Collection 을 하나의 나열된 String 으로 반환합니다..