根据
documentation:
IGNORE is a MySQL extension to standard SQL. It controls how ALTER
TABLE works if there are duplicates on unique keys in the new table or
if warnings occur when strict mode is enabled. If IGNORE is not
specified, the copy is aborted and rolled back if duplicate-key errors
occur. If IGNORE is specified, only one row is used of rows with
duplicates on a unique key. The other conflicting rows are deleted.
Incorrect values are truncated to the closest matching acceptable
value.
也就是说,它用于不同的目的,而不是所有错误.你想要的是ALTER TABLE ADD IF NOT IF EXISTS,并且该语法不存在.
在存储过程中,您可以使用if语句来查看列是否已存在(使用INFORMATION_SCHEMA.COLUMNS).
Here是一个显示相同问题的SQL小提琴.