Lab-verifiedReproduced and fixed on Oracle AI Database 26ai Free 23.26.3.0.0 · 2026-11-25 · container image gvenzl/oracle-free:23-slim
Making a NUMBER column smaller with ALTER TABLE ... MODIFY (fewer total digits, fewer decimal places, or turning plain NUMBER into NUMBER(n)) is only allowed while the column is empty. If any row has a value, the statement fails with ORA-01440, even when every value would fit.
The three cases below show three ways around it, all run on a real database: empty the column and put the values back, move rounded values to a new column, or keep the type and add a CHECK constraint.
01Reducing total digits: NUMBER(10,2) to NUMBER(8,2)
products.price was NUMBER(10,2) with 1200.50 and 89000. ALTER TABLE products MODIFY (price NUMBER(8,2)) failed with ORA-01440.
First MAX(ABS(price)) returned 89000, which fits in NUMBER(8,2). Then: add price_bak, copy the values while setting price to NULL, commit, run the same MODIFY, copy the values back, commit and drop price_bak. user_tab_columns then showed precision 8, scale 2, and the prices were still 1200.5 and 89000.
Setup
CREATE TABLE products (product_id NUMBER, price NUMBER(10,2));
INSERT INTO products VALUES (1, 1200.50);
INSERT INTO products VALUES (2, 89000);
COMMIT;Table created.
1 row created.
1 row created.
Commit complete.ALTER TABLE products MODIFY (price NUMBER(8,2));ALTER TABLE products MODIFY (price NUMBER(8,2))
*
ERROR at line 1:
ORA-01440: column to be modified must be empty to decrease precision or scale
Help: https://docs.oracle.com/error-help/db/ora-01440/SELECT MAX(ABS(price)) AS max_price FROM products; MAX_PRICE
----------
89000
1 row selected.ALTER TABLE products ADD (price_bak NUMBER(10,2));
UPDATE products SET price_bak = price, price = NULL;
COMMIT;
ALTER TABLE products MODIFY (price NUMBER(8,2));
UPDATE products SET price = price_bak;
COMMIT;
ALTER TABLE products DROP COLUMN price_bak;Table altered.
2 rows updated.
Commit complete.
Table altered.
2 rows updated.
Commit complete.
Table altered.Check the maximum first. If a value does not fit the new size, copying it back fails, so the backup column is dropped only at the end.
COLUMN column_name FORMAT A12
SELECT column_name, data_precision, data_scale FROM user_tab_columns WHERE table_name = 'PRODUCTS' AND column_name = 'PRICE';
SELECT product_id, price FROM products ORDER BY product_id;COLUMN_NAME DATA_PRECISION DATA_SCALE
------------ -------------- ----------
PRICE 8 2
1 row selected.
PRODUCT_ID PRICE
---------- ----------
1 1200.5
2 89000
2 rows selected.02Reducing decimal places: NUMBER(10,3) to NUMBER(10,2)
fx_rates.rate was NUMBER(10,3) with 1385.125 and 9.214. MODIFY (rate NUMBER(10,2)) failed with ORA-01440.
A new rate_new NUMBER(10,2) column was filled with ROUND(rate, 2), then the old column was dropped and rate_new renamed to rate. The result was scale 2, with 1385.13 and 9.21.
Setup
CREATE TABLE fx_rates (cur VARCHAR2(3), rate NUMBER(10,3));
INSERT INTO fx_rates VALUES ('USD', 1385.125);
INSERT INTO fx_rates VALUES ('JPY', 9.214);
COMMIT;Table created.
1 row created.
1 row created.
Commit complete.ALTER TABLE fx_rates MODIFY (rate NUMBER(10,2));ALTER TABLE fx_rates MODIFY (rate NUMBER(10,2))
*
ERROR at line 1:
ORA-01440: column to be modified must be empty to decrease precision or scale
Help: https://docs.oracle.com/error-help/db/ora-01440/ALTER TABLE fx_rates ADD (rate_new NUMBER(10,2));
UPDATE fx_rates SET rate_new = ROUND(rate, 2);
COMMIT;
ALTER TABLE fx_rates DROP COLUMN rate;
ALTER TABLE fx_rates RENAME COLUMN rate_new TO rate;Table altered.
2 rows updated.
Commit complete.
Table altered.
Table altered.Using ROUND makes the rounding explicit, so you can check the converted values before dropping the old column.
COLUMN column_name FORMAT A12
SELECT column_name, data_precision, data_scale FROM user_tab_columns WHERE table_name = 'FX_RATES' AND column_name = 'RATE';
SELECT cur, rate FROM fx_rates ORDER BY cur;COLUMN_NAME DATA_PRECISION DATA_SCALE
------------ -------------- ----------
RATE 10 2
1 row selected.
CUR RATE
--- ----------
JPY 9.21
USD 1385.13
2 rows selected.03Changing plain NUMBER to NUMBER(10)
stock.qty was declared as plain NUMBER, holding 120 and 35. MODIFY (qty NUMBER(10)) failed with ORA-01440: from Oracle's point of view this lowers the precision.
Instead of changing the type, a query confirmed there were 0 rows with decimals (qty <> TRUNC(qty)), and a CHECK constraint qty = TRUNC(qty) AND ABS(qty) < 1e10 was added. It was created as ENABLED, and inserting 500 afterwards worked.
Setup
CREATE TABLE stock (item_id NUMBER, qty NUMBER);
INSERT INTO stock VALUES (1, 120);
INSERT INTO stock VALUES (2, 35);
COMMIT;Table created.
1 row created.
1 row created.
Commit complete.ALTER TABLE stock MODIFY (qty NUMBER(10));ALTER TABLE stock MODIFY (qty NUMBER(10))
*
ERROR at line 1:
ORA-01440: column to be modified must be empty to decrease precision or scale
Help: https://docs.oracle.com/error-help/db/ora-01440/SELECT COUNT(*) AS non_integer_rows FROM stock WHERE qty <> TRUNC(qty);NON_INTEGER_ROWS
----------------
0
1 row selected.ALTER TABLE stock ADD CONSTRAINT stock_qty_int_ck CHECK (qty = TRUNC(qty) AND ABS(qty) < 1e10);Table altered.The column type stays NUMBER, so the table needs no rebuild or data copy. The rule is enforced by the constraint instead.
INSERT INTO stock VALUES (3, 500);
COMMIT;
COLUMN constraint_name FORMAT A18
SELECT constraint_name, constraint_type, status FROM user_constraints WHERE table_name = 'STOCK';1 row created.
Commit complete.
CONSTRAINT_NAME C STATUS
------------------ - ------------------------------
STOCK_QTY_INT_CK C ENABLED
1 row selected.FAQ
What does ORA-01440 column to be modified must be empty mean?
You tried to reduce the precision or scale of a NUMBER column that still has data. Oracle only allows that on an empty column.
Why do I get ORA-01440 even though all values fit?
Oracle does not check the values; it refuses any decrease while the column has data. Empty the column first, or use a new column.
How do I reduce decimal places of a NUMBER column?
Add a new column with the smaller scale, fill it with ROUND(old, n), drop the old column and rename the new one.
Why does changing NUMBER to NUMBER(10) give ORA-01440?
Plain NUMBER has the largest precision, so NUMBER(10) counts as a decrease. A CHECK constraint can enforce whole numbers without changing the type.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary users created for the test; system is the DBA account. Oracle AI Database 26ai Free Release 23.26.3.0.0 - Develop, Learn, and Run for Free 23.26.3.0.0