forum

Home / DeveloperSection / Forums / ALTER TABLE with a default: SQL Server vs Oracle

ALTER TABLE with a default: SQL Server vs Oracle

Anonymous User196204-May-2013
Hi Mindstickians!

We have some tables in an Oracle database with several million rows. When we alter one of these tables to add a new column, we specify a default. This is very slow to 

run as Oracle has to update all existing rows with the default. The solution is to ensure the column is defined as NOT NULL because then Oracle (recent versions only) 

will not update all existing rows with the default - the subsequent presence of a null in one of these columns tells Oracle that it requires a default and it will 

provide the default on the fly.

My question is regarding SQL Server: does it exhibit similar behaviour when adding a column and providing a default? If not, are there any best practices in 

efficiently adding new columns with default values, and are there any advantages in defining a column as NOT NULL?

Thanks in advance!

Updated on 04-May-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By