Skip to main content
Incorporated comment
Source Link
Paul White
  • 90.3k
  • 30
  • 424
  • 663

So far I've seen ALTER TABLE RENAME, ALTER TABLE CHANGE and ALTER TABLE MODIFY.

What I'm trying to achieve is something like ALTER TABLE my_table RENAME col_old_name TO col_new_name, which can be a case of modifying a column.

SQLite goes with RENAME.
MariaDB and MySQL have all three.
Postgres goes with RENAME.
Oracle has RENAME and MODIFY.
Standards are unkown to SQL Server.

What is the database-agnostic way for renaming (or generally altering) a column?

Maybe I'm erroneously expecting the standard to cover DDL operations as well? I have code that works with multiple databases so would rather make the SQL part as portable as possible.

So far I've seen ALTER TABLE RENAME, ALTER TABLE CHANGE and ALTER TABLE MODIFY.

What I'm trying to achieve is something like ALTER TABLE my_table RENAME col_old_name TO col_new_name, which can be a case of modifying a column.

SQLite goes with RENAME.
MariaDB and MySQL have all three.
Postgres goes with RENAME.
Oracle has RENAME and MODIFY.
Standards are unkown to SQL Server.

What is the database-agnostic way for renaming (or generally altering) a column?

So far I've seen ALTER TABLE RENAME, ALTER TABLE CHANGE and ALTER TABLE MODIFY.

What I'm trying to achieve is something like ALTER TABLE my_table RENAME col_old_name TO col_new_name, which can be a case of modifying a column.

SQLite goes with RENAME.
MariaDB and MySQL have all three.
Postgres goes with RENAME.
Oracle has RENAME and MODIFY.
Standards are unkown to SQL Server.

What is the database-agnostic way for renaming (or generally altering) a column?

Maybe I'm erroneously expecting the standard to cover DDL operations as well? I have code that works with multiple databases so would rather make the SQL part as portable as possible.

edited tags
Link
Paul White
  • 90.3k
  • 30
  • 424
  • 663
Source Link
vesperto
  • 125
  • 1
  • 2
  • 8

What is the standard SQL way to rename a column?

So far I've seen ALTER TABLE RENAME, ALTER TABLE CHANGE and ALTER TABLE MODIFY.

What I'm trying to achieve is something like ALTER TABLE my_table RENAME col_old_name TO col_new_name, which can be a case of modifying a column.

SQLite goes with RENAME.
MariaDB and MySQL have all three.
Postgres goes with RENAME.
Oracle has RENAME and MODIFY.
Standards are unkown to SQL Server.

What is the database-agnostic way for renaming (or generally altering) a column?