오늘도 한 뼘 더
[MySQL] Error Code 1175: Safe Update 해결 방법 본문
728x90
반응형
# 배경
회사에서 데이터 관련 작업을 진행하는데 update문을 작성하는 중 workbench에서 다음과 같은 에러가 뜨고 실행되지 않는 문제가 발생했다.
Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column. To disable safe mode, toggle the option in Preferences -> SQL Editor and reconnect.
# 해결 방법
작동하려고 한 코드
update item set quantity=0 where quantity is null;
1) 일시적으로 safe update를 해제시키는 방법
다음 코드를 update문을 실행 시키기 전 실행하면 safe update가 해제되면서 update가 가능해진다.
set sql_safe_updates=0;
2) 코드 자체적으로 수정해서 진행하는 방법
id 가 0보다 크다는 걸 명시해주면 불안정한 상태를 막아준다. 이렇게 작성하면 제한을 풀지 않아도 실행이 된다.
update item set quantity=0 where quantity is null and id > 0;
728x90
반응형
'Study > MySQL' 카테고리의 다른 글
[MySQL] 쿼리 플랜(Query Plan) 보기 (0) | 2022.09.15 |
---|---|
[MySQL] MySQL Dump 에러 ERROR 1227 (42000) (0) | 2022.07.15 |
[MySQL] ERROR 2006 (HY000): MySQL server has gone away (0) | 2022.06.03 |
[MySQL] 사용자 생성/삭제, 권한 추가/삭제/변경 (0) | 2022.05.26 |
[MySQL] MySQL Workbench 데이터 이관 작업 (Data Export/Import) (0) | 2021.12.24 |
Comments