DB/SQL

SQL update에러(Error Code: 1175. You are using safe update mode)

씩씩한 IT블로그 2023. 6. 20. 23:38
반응형

SQL update 에러

SQL에서 UPDATE시에 다음과 같은 에러가 나는 경우가 있다.

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를 할 때 where 절에 key 컬럼을 사용하지 않았을 때 발생하는 경고 에러이다.

예시)

update product set price = price-1000 where name like 'shoes%';

 

해결책

key 칼럼을 사용하지 않고도 특정 컬럼을 update하고 싶으면 다음 명령문을 실행한 후 update쿼리를 재동작 하면 된다.

set SQL_SAFE_UPDATES=1;
반응형