wr_id값이

wr_id값이

QA

wr_id값이

본문

코드 만지다가

wr_id값이 엉망이 되어

auto_incresment를 초기화하여 1부터 시작하게 했습니다.

잘되었는데

 

문제는 wr_num값과 wr_parent값은 그대로입니다..

 

이 wr_num을 새로 정렬한 wr_id에 준해서 다시 정리할 수 없을까요?

 

wr_parent값이 동일한거를 불러내고 

그뒤 wr_id값이 낮은것에 맞추어 다시 wr_parent값을 부여한다던지..

 

wr_num값도 비슷한 방법으로 어떻게 할 수 없을까요?

이 질문에 댓글 쓰기 :

답변 2

댓글은 없나요?

댓글이 아닌 글은 wr_id = wr_parent 입니다

댓글이 있으면 wr_id를 변경시켜버리면 안됩니다

 

wr_id 재설정해도 문제 없다면 나머지 변경 방법은 아래 쿼리 실행

sql_query("update 게시판 set wr_num = -1 * wr_id, wr_parent = wr_id ");

 

게시물이 남아 있는 상태에서는

auto_incresment를 초기화하여 1부터 시작하지 못할 텐데요.

 

그럴 리가요.
https://dev.mysql.com/doc/refman/8.0/en/alter-table.html
한번 참고해 보세요.
You cannot reset the counter to a value less than or equal to the value that is currently in use. For both InnoDB and MyISAM, if the value is less than or equal to the maximum value currently in the AUTO_INCREMENT column, the value is reset to the current maximum AUTO_INCREMENT column value plus one.

답변을 작성하시기 전에 로그인 해주세요.
전체 74
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT