Monday, 18 August 2014

Default On Null

Earlier Oracle 12c, we could not able to handle the data in case you want "to insert default value whenever there is a null value getting inserted". Oracle 12c provide this feature to insert default values even though you are providing null value to the column.

This is a specific kind of requirement on handling null values. Many people wants to insert default values instate of null ones. So let's try to find it out how to do it:-

CREATE TABLE EMPLOYEE 
(
  EMP_NO        NUMBER,
  EMP_NAME      NUMBER,
  EMP_DEPT VARCHAR2(20) DEFAULT ON NULL 'HR'
);

INSERT INTO EMPLOYEE VALUES (1, 'CHANCHAL',NULL);

SELECT * FROM EMPLOYEE;

      EMP_NO    EMP_NAME    EMP_DEPT
----------              ---------             ---------
         1         CHANCHAL          100
       

1 rows selected.





Read Also:-  

No comments:

Post a Comment