SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


When adding new column to table, where is that data stored ?


When adding new column to table, where is that data stored ?

Author
Message
sqld-_-ba
sqld-_-ba
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3503 Visits: 1159

When a row exceeds 8060 bytes, a ROW_OVERFLOW_DATA page and pointer are created, to fit the 8KB page size limit.

What happens when a new column is added to an existing table :

Is the data stored at the 'end' of the table, and pointers are created after each existing row in a page to point to this new data, similar to ROW_OVERFLOW_DATA (even if adding new column does not exceed row size over 8060 bytes) ?

Or is the entire table reorganized so the new column 'fits' in the original page ?



GilaMonster
GilaMonster
SSC Guru
SSC Guru (747K reputation)SSC Guru (747K reputation)SSC Guru (747K reputation)SSC Guru (747K reputation)SSC Guru (747K reputation)SSC Guru (747K reputation)SSC Guru (747K reputation)SSC Guru (747K reputation)

Group: General Forum Members
Points: 747039 Visits: 48477
The new column has to fit on the original page.
If it's also varchar/nvarchar/varbinary, then it too can have portions of its data sent out to row_overflow pages

And your first sentence isn't exactly true. What happens is that the variable columns can have some/all of their contents put on overflow pages. Those pages are not the same structure as the data page, they're closer to how the MAX data types are stored.

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


sqld-_-ba
sqld-_-ba
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3503 Visits: 1159
>The new column has to fit on the original page.
Does that mean the entre table/leaf node pages have to be re-organised ? That way there is no 'row chaining' like in oracle which causes performance issues due to reading from addition pointer pages, correct?
GilaMonster
GilaMonster
SSC Guru
SSC Guru (747K reputation)SSC Guru (747K reputation)SSC Guru (747K reputation)SSC Guru (747K reputation)SSC Guru (747K reputation)SSC Guru (747K reputation)SSC Guru (747K reputation)SSC Guru (747K reputation)

Group: General Forum Members
Points: 747039 Visits: 48477
There's no such thing as 'row chaining'. A row must fit onto a single page, the only exceptions being that data in varchar, nvarchar & varbinary columns can be partially or completely stored off-page (not good for performance though)

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


shwetakakran01
shwetakakran01
Valued Member
Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)

Group: General Forum Members
Points: 60 Visits: 12
first write table name after Alert table query.
Alter table table_name add column column_name.

you can add one or more column at a same time.
shwetakakran01
shwetakakran01
Valued Member
Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)

Group: General Forum Members
Points: 60 Visits: 12
new column add to the original table. to add new column use alter command.
shwetakakran01
shwetakakran01
Valued Member
Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)

Group: General Forum Members
Points: 60 Visits: 12
new column added or stored to original page.
shwetakakran01
shwetakakran01
Valued Member
Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)Valued Member (60 reputation)

Group: General Forum Members
Points: 60 Visits: 12
your new column add to page that already contain your table.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search