Adding Column to a SQL Server Table
The next thing you could do is, examine the data pages. For this as in the previous case, the DBCC PAGE is an undocumented DBCC command.
DBCC TRACEON(3604) DBCC PAGE (AddColumn, 1, 154, 3);
You need to switch on trace switch 3604 for DBCC Page command.
If you analyze page number 154 as shown in the example above, you will see the newly added column.
What does this mean? Is to say that even a Nullable column will modify the data pages? If that is the case, there shouldn’t be much different from adding a nullable column or adding a column with a default value, which is not what we saw in the first table.
Let us analyse lsn number of the page. Lsn is the Log Sequence Number of the last log record that changed the page.
You will see that there is no change to the lsn before and after adding the nullable column while there is a change to the lsn value, if you add a column with a default value.
This tells us two things.
1. This confirms that there are no physical changes to the data pages
when you are adding a nullable column.
2. DBCC PAGE is not simply showing data dump of the data page.
When adding a column to a large table, the best practice would be adding a nullable column. However, if you want to update existing rows, consider using the Update statement after adding a nullable column.
Pages: 1 2