#4891 - Properly abstract ALTER queries
| Identifier | #4891 |
|---|---|
| Issue type | Minor issue (breaks specific functionality) |
| Title | Properly abstract ALTER queries |
| Status | Completed |
| Tags |
Roadmap: v11 (custom) |
| Handling member | Chris Graham |
| Addon | core_database_drivers |
| Description | There is currently no proper abstraction for ALTER database queries for database drivers other than mysqli.
For example, MySQL / MariaDB uses CHANGE COLUMN, but Oracle and PostgreSQL use RENAME COLUMN. MSSQL uses something entirely different. https://www.techonthenet.com/sql/tables/alter_table.php |
| Steps to reproduce | |
| Funded? | No |
The system will post a comment when this issue is modified (e.g., status changes). To be notified of this, click "Enable comment notifications".


Comments
Only MySQL 8+ / MariaDB 10.5+ supports the "RENAME COLUMN" syntax. (which is better as the field type does not need respecifying)
Altering table column types also varies based on DB.
I think most DBs don't support altering column types and renaming at the same time like MySQL does - meaning we'll need to split the operations in our code.
I do not know what the ANSI standards are, if there are any for this kind of query.
https://www.techonthenet.com/sql/tables/alter_table.php
The ANSI standard is *horrible* to read, it's all defining a formal grammar and doesn't even show any examples of real SQL. Rant: What's the point of going to the extreme effort to define a standard in formal grammar (and failing to make a spec that is actually readable), when you can't even get any vendor to implement the standard well? (none do)