MySql - Create Table If Not Exists Else Truncate?

前端 未结 6 1659
隐瞒了意图╮
隐瞒了意图╮ 2020-12-31 00:23

Here is the updated question:

the current query is doing something like:

$sql1 = \"TRUNCATE TABLE fubar\";
$sql2 = \"CREATE TEMP         


        
6条回答
  •  长发绾君心
    2020-12-31 00:45

    You could do the truncate after the 'create if not exists'. That way it will always exist... and always be empty at that point.

    CREATE TABLE fubar IF NOT EXISTS
    TRUNCATE TABLE fubar
    

提交回复
热议问题