Mysql: RENAME TABLE IF EXISTS

后端 未结 8 1261
甜味超标
甜味超标 2020-12-10 01:08

This DROP TABLE IF EXISTS works, too bad that RENAME TABLE IF EXISTS doesn\'t work.

Can anyone suggest a solution for this query?



        
8条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-10 02:13

    First create table IF NOT EXISTS. Then RENAME it, so it will always exist!

    Otherwise, rename the table, and if it doesn't exist just handle the error.

    It is obvious, but it works.

提交回复
热议问题