How to resolve ORA-01440 Error Message in Oracle database

Learn the cause and how to resolve the ORA-01440 error message in Oracle.

Description

When you stumble upon an ORA-01440 error, the following error message will appear:

ORA-01440: column to be modified must be empty to decrease precision or scale

Cause

You tried to execute a ALTER TABLE MODIFY announcement on a numeric column to decrease precision or scale, but the column contained data. You can solely alter the numeric column whose values are all NULL.

Resolution

The option(s) to resolve this Oracle error are:

Option #1

Execute an UPDATE announcement to alternate all values in that column to NULL.

Option #2

Execute a DELETE assertion to cast off all rows from the table.

For example, if you had a desk referred to as suppliers described as follows:

CREATE TABLE suppliers
( supplier_id number(5),
  discount number(5,2)
);

Then executed an INSERT statement as follows:

INSERT into suppliers
(supplier_id, discount)
VALUES (12345, 30.25);

And you tried to execute the following ALTER TABLE statement:

ALTER TABLE suppliers
 MODIFY discount number(4,2);

You would receive the following error message:

You could right the error with either of the following solutions:

Solution #1

You can replace the bargain column to all NULLs. This only works if the discount discipline will receive NULL values.

UPDATE suppliers
SET discount = NULL;

Solution #2

You can put off all entries from the suppliers table.

DELETE FROM suppliers;

If you do decide to delete all entries from your suppliers table, you would possibly choose to make sure that you have a backup of the data.