Mysql Update시 AutoCommint 여부 변경

Mysql Update시 AutoCommint 여부 변경

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. 0.000 sec

Mysql Update 시 위와 같이 1175 오류가 나면, 안전 업데이트 값을 변경해줘야 한다.

SET SQL_SAFE_UPDATES = 0; 하면 업데이트가 된다.

그런데 이 때, 만약 autocommit 이 true라면, 실수할 가능성이 있다.

따라서 SET SQL_SAFE_UPDATES = 0; 에 이어 set autocommit = 0; 을 써줘야 한다. (오토커밋 해제)

오토커밋 조회

SELECT @@AUTOCOMMIT; 

오토커밋 적용
set autocommit = 1;
set autocommit = TRUE;

오토커밋 해제
set autocommit = 0;

set autocommit = FALSE;