키워드 및 예약어를 식별자로 사용하는 방법

minstone·2022년 11월 19일
0
post-thumbnail

환경

mysql 5.7.21 -> mysql 8.0.26 복제구성



이슈

프로시저 반영 중 SOURCE 서버에는 생성되었으나 REPLICA서버에는 생성되지 않고 복제중단.



원인 및 해결

  • "RANK" 단어가 REPLICA버전에서는 키워드 및 예약어로 추가됨.
  • 키워드 및 예약어를 식별자로 사용하기위해서는 `(역따옴표) 로 묶어주면 식별자 사용 가능함.

MySQL :: MySQL 5.7 Reference Manual - Keywords and Reserved Words

#예약어인 SELECT는 테이블명으로 사용 불가
mysql (test)>create table select(c1 int);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select(c1 int)' at line 1

#따옴표로 감싸면 예약어도 변수명으로 사용 가능
mysql (test)>create table `select`(c1 int);
Query OK, 0 rows affected (0.01 sec)
mysql (test)>show tables;
+---------------------+
| Tables_in_test      |
+---------------------+
| select              |
+---------------------+
1 rows in set (0.00 sec)
profile
🌚Stone Kid

0개의 댓글