Fraser
Fraser

Reputation: 1010

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?

Upvotes: 6

Views: 5110

Answers (2)

Peter Bratton
Peter Bratton

Reputation: 6408

Check to make sure the column has the dataType you suspect. Your migration will work if the original dataType is NUMBER(N,0) where N < 38.

Upvotes: 0

Mohammad Nadeem
Mohammad Nadeem

Reputation: 9392

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.

Upvotes: 1

Related Questions