How to Resolve ORA-01440 | Column to Be modified must be empty to decrease precession or scale

Pubblicato il: 07 dicembre 2022
sul canale di: Oracle Training-Free Oracle Tutorials
164
2

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


In questa pagina del sito puoi guardare il video online How to Resolve ORA-01440 | Column to Be modified must be empty to decrease precession or scale della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Oracle Training-Free Oracle Tutorials 07 dicembre 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 164 volte e gli è piaciuto 2 spettatori. Buona visione!