How to Resolve ORA-01440 | Column to Be modified must be empty to decrease precession or scale | how to change the precision when table contains data in oracle | changing column type in oracle
1. Check the Column's Precision
describe abc;
Name Null? Type
----------------------------------------- -------- ---------------
EMPNO VARCHAR2(30)
ENAME VARCHAR2(20)
JOB VARCHAR2(20)
SALARY NUMBER(25)
DEPARTMENT NUMBER(10)
As you can see, the column SALARY is defined with NUMBER data type as NUMBER(25).
Solution to ORA-01440
1. Add a New Column
alter table abc
add salary2 number(20);
2. Backup Data
update abc
set salary2=salary;
3. Empty the Old Column
update abc
set salary = null;
4. Modify the Old Column
alter table abc modify salary number(20);
5. Restore Data
update abc
set salary=salary2;
6. Drop the Backup Column
alter table abc
drop column salary2;
7. Check the Column's Precision
describe abc;
Name Null? Type
----------------------------------------- -------- ------------
EMPNO VARCHAR2(30)
ENAME VARCHAR2(20)
JOB VARCHAR2(20)
SALARY NUMBER(20)
DEPARTMENT NUMBER(10)
We have decreased the precision of the column.
#sqlqueries #oracletutorial #oracleinterviewquestions #plsql #ORA-01440
Sur cette page du site, vous pouvez voir la vidéo en ligne How to Resolve ORA-01440 | Column to Be modified must be empty to decrease precession or scale durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Oracle Training-Free Oracle Tutorials 07 décembre 2022, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 164 fois et il a aimé 2 téléspectateurs. Bon visionnage!