문제

I have a databse called store having 100 tables having too much foreign key references with tables, having thousands of records.

Problem: Is it possible something like truncate to delete all the rows of all the tables in a single query.

I tried but I am not able to find the exact way to achieve this when I try to TRUNCATE TABLE it gives me error: Cannot delete or update a parent row: a foreign key constraint fails which is expected too.

Can anyone please help me to achieve this, or suggest me the better way to do this.

도움이 되었습니까?

해결책

Do this before deleting:

SET FOREIGN_KEY_CHECKS=0;

When finished, reset it to 1:

SET FOREIGN_KEY_CHECKS=1;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top