[MDEV-16290] ALTER TABLE ... RENAME COLUMN syntax Created: 2018-05-25  Updated: 2022-12-01  Resolved: 2020-03-03

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Parser
Fix Version/s: 10.5.2

Type: Task Priority: Critical
Reporter: Enrique Matías Sánchez Assignee: Aleksey Midenkov
Resolution: Fixed Votes: 5
Labels: Compatibility

Issue Links:
Problem/Incident
causes MDEV-23852 alter table rename column to uppercas... Closed
Relates
relates to MDEV-17567 Atomic DDL Closed
relates to MDEV-7318 RENAME INDEX Closed
relates to MDEV-21889 IF EXISTS clause does not work for RE... Closed
relates to MDEV-21941 RENAME doesn't work for system time o... Closed
relates to MDEV-22881 Unexpected errors, corrupt output, Va... Closed
relates to MDEV-28576 RENAME COLUMN with NOCOPY algorithm l... Closed

 Description   

To rename a column, MariaDB provides this syntax:

ALTER TABLE <table_name> CHANGE COLUMN old_name new_name column_definition

which requires re-specification of all the attributes of the column.

Disadvantages of the above syntax :

  • All the column information might not be available to the application trying to
    do the rename.
  • There is a risk of accidental data type change in the above syntax which might
    result in data loss.

The proposed syntax, supported by MySQL 8.0, Oracle and PostgreSQL, is:

ALTER TABLE <table_name> RENAME COLUMN old_name TO new_name;

The new proposed syntax is expected to behave the same as "ALTER TABLE ...
CHANGE" command used to rename column, without changing column attributes.

The old syntax "ALTER TABLE ... CHANGE" to rename the column will continue
to work.

MySQL tickets: WL#10761, WL#6555



 Comments   
Comment by Aleksey Midenkov [ 2019-06-13 ]

Good point. MySQL 8.0 already has it. Should be done along with RENAME {INDEX|KEY}.

https://dev.mysql.com/doc/refman/8.0/en/alter-table.html

Question on StackOverflow: Does MariaDB support renaming an index?

Comment by Enrique Matías Sánchez [ 2020-03-03 ]

Thanks, Aleksey!

Generated at Thu Feb 08 08:27:48 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.