Skip to content

Instantly share code, notes, and snippets.

@thetekst
Last active August 5, 2022 14:57
Show Gist options
  • Save thetekst/0d5c5c186dac888cd7c3f0b1fd699abf to your computer and use it in GitHub Desktop.
Save thetekst/0d5c5c186dac888cd7c3f0b1fd699abf to your computer and use it in GitHub Desktop.
liquibase. oracle. fix ORA-22858: invalid alteration of datatype; ORA-01439: column to be modified must be empty to change datatype
databaseChangeLog:
- changeSet:
id: 2021100110000
author: test
changes:
- addColumn:
tableName: example_tab
columns:
- column:
name: rock_new
type: clob
- update:
tableName: example_tab
columns:
- column:
name: rock_new
valueComputed: rock # update value form "rock" column
- dropColumn:
columnName: rock
tableName: example_tab
- renameColumn:
columnDataType: clob
oldColumnName: rock_new
newColumnName: rock
tableName: example_tab
rollback:
- addColumn:
tableName: example_tab
columns:
- column:
name: rock_new
type: varchar2(255)
- update:
tableName: example_tab
columns:
- column:
name: rock_new
valueComputed: rock
- dropColumn:
columnName: rock
tableName: example_tab
- renameColumn:
columnDataType: varchar2(255)
oldColumnName: rock_new
newColumnName: rock
tableName: example_tab
# sql https://stackoverflow.com/a/13402577
# ALTER TABLE some_table ADD (foo CLOB);
# UPDATE some_table SET foo = old_column;
# ALTER TABLE some_table DROP COLUMN old_column;
# ALTER TABLE some_table RENAME COLUMN foo TO old_column;
# the next option doesn't work
# - modifyDataType:
# columnName: rock
# newDataType: clob
# tableName: example_tab
# - rollback:
# - modifyDataType:
# columnName: rock
# newDataType: varchar(255)
# tableName: example_tab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment