Bug #115738 | Modify column length, and the column name case was changed. | ||
---|---|---|---|
Submitted: | 1 Aug 2024 9:00 | Modified: | 2 Aug 2024 2:17 |
Reporter: | yongguang liao | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: DDL | Severity: | S3 (Non-critical) |
Version: | 8.0.15 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | 8.0.15, modify column |
[1 Aug 2024 9:00]
yongguang liao
[1 Aug 2024 9:11]
MySQL Verification Team
Hi Mr. weew, Thank you for your bug report. However, this is not a bug. Simply, SQL is a case-insensitive interpreter, so you can mix uppercase and lowercase letters in keywords and column names. When it comes to table names, it depends on the operating system and your MySQL settings. Regarding string literals, whether they are case sensitive or not, depends on the collation chosen. But, column names, functions, keywords are case insensitive , as defined by the SQL Standard. Not a bug.
[1 Aug 2024 9:26]
yongguang liao
Thank you for your prompt response.core_coupon_rec_inf I understand that column names are case-insensitive at the SQL level, so using lowercase in ALTER TABLE can still modify the field length. However, being case-insensitive does not mean that ALTER TABLE ... MODIFY can change the case of the column name, right? My understanding is that while SQL does not distinguish case when using the names, the column name itself should not be changed arbitrarily. To change the column name, should we use ALTER TABLE ... CHANGE? I'm not sure if my understanding is correct.
[1 Aug 2024 9:45]
MySQL Verification Team
Hi Mr. weew, Unfortunately, your understanding is not correct. SQL is case insensitive language, except for the cases that we already described. Also, MySQL is trying, whenever it is possible, to do what ever user commands. This is a behaviour demanded by millions of our users. So, to get the case of your choice, you should use the case of your choice. Not a bug.
[2 Aug 2024 1:43]
yongguang liao
Thank you for your patient and detailed response. I understand your point. MySQL is trying, whenever possible, to follow user commands. It tries to be as fault-tolerant as possible and do what the user intends. In the MySQL development manual, at the address: https://dev.mysql.com/doc/refman/8.4/en/alter-table.html, in the section "Renaming, Redefining, and Reordering Columns," it mentions: MODIFY: Can change a column definition but not its name. More convenient than CHANGE to change a column definition without renaming it. With FIRST or AFTER, can reorder columns. The document then provides an example: To change a column definition but not its name, use CHANGE or MODIFY. With CHANGE, the syntax requires two column names, so you must specify the same name twice to leave the name unchanged. For example, to change the definition of column b, do this: ALTER TABLE t1 CHANGE b b INT NOT NULL; MODIFY is more convenient to change the definition without changing the name because it requires the column name only once: ALTER TABLE t1 MODIFY b INT NOT NULL;
[2 Aug 2024 2:17]
yongguang liao
Add the following: In the MySQL development manual, at the address: https://dev.mysql.com/doc/refman/8.4/en/alter-table.html, in the section 15.1.9 ALTER TABLE Statement, in the part Renaming, Redefining, and Reordering Columns,