Notice
Recent Posts
Recent Comments
Link
«   2025/12   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Archives
Today
Total
관리 메뉴

자르비 왕국

[MySQL] Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger. 본문

Development/DB

[MySQL] Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.

자르비옹스 2022. 3. 5. 23:22

MySQL에서 사용자가 탈퇴했을 때, follow/follower 수를 user 테이블의 field에서 -1씩 해주도록 트리거를 설정하였다. 그러나 그렇게 설정한 뒤에

더보기

Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.

이라는 에러가 발생하였다. 구글링을 해서 찾아보니 해당 테이블을 트리거할 수 없다는 것이었다.

 

또한, cascade로 인하여 delete된 데이터의 경우 trigger를 실행시키지 않는다고 한다. 따라서, cascade대신 trigger를 걸어두어 다른 데이터에게도 영향을 미치도록 해야한다.

'Development > DB' 카테고리의 다른 글

[MySQL] node.js 다중 쿼리  (0) 2022.03.06