Groups | Blog | Home
all groups > sql server misc > october 2005 >

sql server misc : question about log file size when alter Huge table


Gordowey
10/30/2005 4:33:42 PM
I have the next question, and i would like to hear what do you think
about, and if is there a better solution for "my problem"


here is the question, I have a huge table with 60GB of data (image
files). The problem happen always when i try to ALTER the structure of
the table. For example I change a field char(3) to char(4)...the
sqlserver then performs the "alter table" command...that must be
something similar than "insert into the new table + drop the actual
table" and for that I need about 60GB o space for my LOG file, and
takes hours to complete the operation.


Is this the only way to alter a single field in my table??


I would like to heard you opinions...Thanks..


ALberto
Danny
10/31/2005 12:38:20 PM
Alberto,

EM is a brute force kind of tool. You are correct that it is creating a new
table and doing inserts. This is very inefficent. There's a script button
on the tool bar in design mode tat will let you see what EM is going to do.
When altering a table, some changes have to populated in every row and
others don't. Changing a char field changes every row. In this case addes
one blank space. Using varchar instead of char would allow for some
flexibility. However, if you need to change every row don't use EM on a
table this large. Try putting your DB in simple recovery mode. Use a
select into command to create another table but not logged. Add
constraints, permissions, and indexes. Drop the old table and rename the
name table to the old table name. Put your DB back in Full recovery mode.
Perform a backup...

[quoted text, click to view]

Gordowey
11/1/2005 12:50:28 PM
thanks for your help!!

regards

Alberto
AddThis Social Bookmark Button