Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Adding a column to a table with DEFAULT (0)

Author  Topic 

magictech
Starting Member

44 Posts

Posted - 2004-09-30 : 11:31:40
The process of adding a column with DEFAULT (0) value to one of my table takes a very long time. This table has about 14 million records. Now I’m wondering if adding a column to a table with a default value takes longer than adding a column without a default value? Any information would be greatly appreciated.

Thanks

In advance

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2004-09-30 : 11:39:08
just adding a default value to a column doesn't add much overhead (that I am aware of). However, i think I might know what is going on.

Did you add the column using Enterprise Manager, or using Query Analyzer? If EM, did you place it at the beginning of your column list, or just add it to the end?

The reason I ask is EM will script a new table and insert all the records from the original table into the new one. After that is done it will drop the original and rename the new to match the old. If you have any indexes they will all be rebuilt as well.

If you just altered the table and added a column in QA, the column would have been added to the end and default values would have been generated very quickly.


-ec
Go to Top of Page

magictech
Starting Member

44 Posts

Posted - 2004-09-30 : 11:51:54
Thanks for your responds.

The column is added through a FoxPro script using ALTER TABLE ADD column statement.

Thanks in advance.


Regards
Go to Top of Page
   

- Advertisement -