Saturday, March 19, 2011

Adding a Column to SQL Server table

If you are DBA, I am sure you have added columns to tables 1000+ times. But, you know when you are adding a column to a large table, you need extra care. Read the new article on this subject.

2 comments:

  1. This is a nice article..
    Its very easy to understand ..
    And this article is using to learn something about it..

    c#, dot.net, php tutorial, Ms sql server

    Thanks a lot..!

    ReplyDelete
  2. Posted by Orlando Colamatte at LinkedIn Group : SQL Server 2008
    Adding a column in the middle of a table can provide some value in terms of performance over adding it as the last column in the table.

    Adding a column to the middle of a table however requires more steps to implement:
    1. create a new table with the additonal column in the correct place in the middle of the table all while ensuring the indexes, constraints, keys, partitioning and triggers carry forward to the new table
    2. copy the data from the existing table into the new table
    3. drop the existing table
    4. rename the new table to take the place now vacated by the current table

    Whereas adding a column to the end of a table only requires a simple ALTER TABLE statement.

    ReplyDelete