'Is the COLUMN keyword in MySQL optional?
In commands like the where the DROP clause is used
ALTER TABLE DROP <column>
and
ALTER TABLE DROP COLUMN <column>
are both accepted.
Are there any commands in which the COLUMN keyword is not optional or is it optional everywhere?
Solution 1:[1]
From MySQL docs
The word COLUMN is optional and can be omitted, except for RENAME COLUMN (to distinguish a column-renaming operation from the RENAME table-renaming operation).
Solution 2:[2]
It is clear in the syntax reference where the COLUMN keyword is optional:
| DROP [COLUMN] col_name
The square-brackets notation in the syntax reference means that the word inside the brackets is optional. See the linked documentation page for other cases of optional keywords.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ergest Basha |
| Solution 2 | Bill Karwin |
