-- 清空指定表的数据
-- 按照外键依赖关系的顺序删除

SET FOREIGN_KEY_CHECKS = 0;

-- 清空评分相关表
DELETE FROM t_activity_rating_item;
DELETE FROM t_activity_rating;

-- 清空活动选手表
DELETE FROM t_activity_player;

-- 清空活动评委表
DELETE FROM t_activity_judge;

-- 清空选手表
DELETE FROM t_player;

-- 清空活动表
DELETE FROM t_activity;

SET FOREIGN_KEY_CHECKS = 1;

-- 验证清空结果
SELECT 'Tables cleared successfully' as result;
SELECT 
    't_activity' as table_name, COUNT(*) as record_count FROM t_activity
UNION ALL
SELECT 
    't_activity_player' as table_name, COUNT(*) as record_count FROM t_activity_player
UNION ALL
SELECT 
    't_activity_judge' as table_name, COUNT(*) as record_count FROM t_activity_judge
UNION ALL
SELECT 
    't_activity_rating' as table_name, COUNT(*) as record_count FROM t_activity_rating
UNION ALL
SELECT 
    't_activity_rating_item' as table_name, COUNT(*) as record_count FROM t_activity_rating_item
UNION ALL
SELECT 
    't_player' as table_name, COUNT(*) as record_count FROM t_player;