본문 바로가기
기타

Mysql 5.x 에서 8.x 마이그레이션 하기

by zgabriel 2024. 8. 22.
728x90

디비는 웬만하면 건드리고 싶지 않은데 강제적으로 업데이트 해야하는 일이 발생했다.

빌어먹을 AWS ㅡㅡ; 왜 자꾸 등을 떠미는지...

어쨌든, 마이그레이션을 진행하게 되어서 어떤 쿼리를 수정해줘야 하는지 체크해봤다. 

1. 서브쿼리 내 정렬불가


 . 8.x 에서 새롭게 변경된 내용은 아닌 듯 하나, 쿼리 확인 과정에서 데이터가 상이했던 부분이라 수정해야함.
 . 5.x 에서는 서브쿼리 내 order by 처리를 하면 정렬된 데이터를 그대로 활용할 수 있었으나, 업그레이드한 버전에서는 모든 테이블(서브쿼리로 select된 테이블 포함)내 데이터의 정렬은 의미가 없다고 본다
 . 서브쿼리로 원하는 데이터가 있다면 단순 정렬이 아니라 집계 함수등을 이용하여 정확한 데이터를 찾아주어야 한다
 . 참고자료

    https://mariadb.com/kb/en/why-is-order-by-in-a-from-subquery-ignored

 

Why is ORDER BY in a FROM Subquery Ignored?

Query with ORDER BY in a FROM subquery produces an unordered result.

mariadb.com

 

2. group by 정렬 기능 종료


 . 이전 버전에는 group by 사용시 그룹핑에 사용된 필드를 기준으로 오름차순 정렬이 디폴트로 적용되었으나, group by 정렬 자체가 지원 종료됨에 따라 쿼리 수정이 필요하다
 . 그룹화+정렬이 필요한 쿼리뿐만 아니라 group by idx asc, group by idx desc 구문 자체가 지원이 종료되었으므로 해당 쿼리를 사용하였다면 수정을 해주어야 한다
 . 참고자료

    https://dev.mysql.com/worklog/task/?id=8693

 

MySQL :: WL#8693: Remove the syntax for GROUP BY ASC and DESC

WL#8693: Remove the syntax for GROUP BY ASC and DESC Affects: Server-8.0   —   Status: Complete In MySQL, historically GROUP BY has been used for sorting. If a query specifies GROUP BY, output rows were sorted according to the GROUP BY columns as if th

dev.mysql.com

 

3. binary 연산자 지원 종료


 . 대/소문자 구분 또는 한글 정렬등을 위해 사용하던 binary 연산자가 지원이 종료됨에 따라 수정이 필요함
 . binary 연산자 뿐만 아니라 float(m,d), double(m,d) 구문, &&, ||, ! 연산자도 지원이 종료되었으니 수정이 필요하다
 . 참고문서

    https://dev.mysql.com/doc/refman/8.4/en/cast-functions.html

 

MySQL :: MySQL 8.4 Reference Manual :: 14.10 Cast Functions and Operators

MySQL 8.4 Reference Manual  /  Functions and Operators  /  Cast Functions and Operators 14.10 Cast Functions and Operators Table 14.15 Cast Functions and Operators Name Description Deprecated BINARY Cast a string to a binary string Yes CAST() Cast a

dev.mysql.com

 

 

반응형