default constraint updating existing rows

From: Harvinder Singh <>
Date: Tue, 16 Dec 2008 13:22:15 -0500
Message-ID: <>


We are adding a column with default constraint and we only want it to apply to new rows but it is updating existing rows even though column allows null. I am using the following test:

SQL> create table test (a int);

Table created.

SQL> insert into test values(1);

1 row created.

SQL> insert into test values(2);

1 row created.

SQL> alter table test add b int default 3;

Table altered.

SQL> select * from test;

         A B
---------- ----------

         1          3
         2          3

SQL> desc test
 Name                                      Null?    Type
 ----------------------------------------- -------- --------------

 A                                                  NUMBER(38)
 B                                                  NUMBER(38)

Is there any way to add new column with default constraint without updating existing rows?


The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access or use by any other person to this internet email is not authorized and may be unlawful. If you are not the intended recipient, please delete or destroy this email. If you do not wish to receive future emails from this sender, please reply directly to this email requesting you be removed from any mailing list.

-- Received on Tue Dec 16 2008 - 12:22:15 CST

Original text of this message