[MySQL]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.

코코·2020년 10월 22일
0
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.

"안전 업데이트 모드를 사용 중이며 KEY 열을 사용하는 WHERE없이 테이블을 업데이트하려고했습니다. 안전 모드를 비활성화하려면 기본 설정-> SQL 편집기에서 옵션을 토글하고 다시 연결합니다."

MySQL에서 update하던 중 에러가 발생했다.

게시글 목록을 담아두는 테이블 tbl_board에 각 게시글에 달린 댓글 수를 조회할 수 있도록 replyCount라는 컬럼을 만들었다.
기존의 댓글 수를 조회해서 tbl_board의 replyCount컬럼에 대입하려고

UPDATE tbl_board 
SET replyCount = (
    SELECT count(rno) 
    FROM tbl_reply
    WHERE tbl_reply.bno = tbl_board.bno
);

이렇게 업데이트 쿼리를 날렸더니

1175에러가 발생했다. 이 에러는 전에도 한 번 해결한 적 있는 에러였다. 약간의 설정을 하는 것만으로 간단하게 해결할 수 있었다.

Workbench 상단 메뉴 edit -> Preferences로 들어간 다음, SQL Editor탭을 클릭한다.

Other부분에 있는 Safe Updates 체크박스를 풀어주면 해결된다.

0개의 댓글