开发者

mysql: alter tablename only if table exists

开发者 https://www.devze.com 2023-02-28 20:43 出处:网络
I tried writing query using exists, but no success so开发者_运维技巧 far. Searching hasn\'t helped so far.If you attempt to alter a table that does not exist, the query will fail with an error: Table

I tried writing query using exists, but no success so开发者_运维技巧 far. Searching hasn't helped so far.


If you attempt to alter a table that does not exist, the query will fail with an error: Table 'database.table' doesn't exist

MySQL does support ALTER IGNORE TABLE, but that only turns errors into warnings if you're attempting to create a unique index while there are values in the table that violate that index.

If you would like to make sure that you do not produce any database queries, I would suggest ensuring the table's existence using SHOW TABLES LIKE 'tablename' before running your ALTER TABLE query.

0

精彩评论

暂无评论...
验证码 换一张
取 消