Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify dataType for columns with data in Oracle using Liquibase

I am trying to modify the dataType from NUMBER(10,0) to NUMBER(30,0) against a database with data in these columns. I have to use liquibase for this. I am using the following:

<modifyDataType tableName="tableName" columnName="columnsName" newDataType="NUMBER(38,0)"/>

But for the tables with data in the columns I get the following error:

Caused by: java.sql.SQLException: ORA-01440: column to be modified must be empty to decrease precision or scale

And the column is not migrated. Can columns with data not be migrated to a new type by this method?

like image 711
Fraser Avatar asked Nov 12 '22 09:11

Fraser


1 Answers

Its not liquibase, its the oracle engine which throws this error. Liquibase actually converts modifyDataType to an alter table statement. So your statement which goes to oracle engine will be like:

ALTER TABLE tableName MODIFTY columnsName NUMBER(38,0);

Now modifyDataType will return any error returned as a result of the generated sql statement.

like image 122
Mohammad Nadeem Avatar answered Nov 24 '22 01:11

Mohammad Nadeem