Reputation: 14554
Why does dropping a non-existent table IF EXISTS
cause a warning?
CREATE DATABASE `test`;
USE `test`;
DROP TABLE IF EXISTS `nonexistent_table`;
SHOW WARNINGS;
Unknown table 'test.nonexistent_table'
Isn't the whole point of this statement to check if it exists first, and accept that it might not exist?
Upvotes: 3
Views: 1326
Reputation: 24593
the different it it doesn't give you an error but just warning:
DROP TABLE IF EXISTS `nonexistent_table`; SHOW WARNINGS;
✓ Level | Code | Message :---- | ---: | :---------------------------------------------- Note | 1051 | Unknown table 'db_2134513036.nonexistent_table'
DROP TABLE `nonexistent_table`; SHOW WARNINGS;
Unknown table 'db_2134513036.nonexistent_table'
db<>fiddle here
as you see first statement runs successfully but second one fails.
Upvotes: 3