Monday, 29 April 2013

Alter Table With Default Constraint


case1:-
========
When you are adding a column into an existing table with default constraint then it takes lot of time to add, if the table is big.

Why because adding column with default value means you are updating the total table with that value.

ex: ALTER TABLE Scott.EMP ADD (emp_flag VARCHAR2(1) DEFAULT 'N');

case2:-
========
When you are adding a column into an existing table without default constraint,
it doesnot take time even though you are adding it into a big table.

Why because adding a column without default value means it doesnot go for updating your table. It just adds a column with null values.

ex: ALTER TABLE Scott.EMP ADD (emp_flag VARCHAR2(1));

Note:- Based on your requirement go for adding.