Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试将表的范围从 1 截断到 100。
for ($i=1; $i<100; $i++){ $qryTruncate = "TRUNCATE `tbl_$i`"; $resultTruncate = mysqli_query($conn, $qryTruncate); }
截断所有表需要很长时间。
你有什么建议让它更快吗?
您可以做的是删除表并像这样重新创建它。
重命名表 -> 创建类似的新表 -> 删除旧表
for ($i=1; $i<100; $i++){ mysqli_query($conn, "RENAME TABLE `tbl_$i` `temp_tbl_$i`"); mysqli_query($conn, "CREATE TABLE `tbl_$i` LIKE `temp_tbl_$i`"); mysqli_query($conn, "DROP TABLE `temp_tbl_$i`"); }