alter column v. copy table

  • Need to alter a column in a table, from varchar(20) to varchar(50).

    My initial reaction was to use alter table alter column, however after researching the table I'm not so sure this would be the best approach.

    Table has 14+ million rows, over 9GB in total size.

    Would it be better to create a copy of the table and insert the records into the copy (with the modified column length)?  One thing to note is that the table has one text column, everything else is either int, datetime or varchar.

    When using the alter table approach I'm assuming that I would be doing a delete and an insert for every row (for a total of 28+ Million operations), but if I use the copy table approach would only be doing inserts (14+ Million operations).

    Thoughts?

    TIA

    Angela

  • no, since the column is already variable, increasing the variable size should be instantaneous, if it was a fixed char, and increasing the char length, it would take foreeeevvvvveeeerrrrr. Do not recommend copying table, just use alter table.

    Is there a way you can test on a smaller table?

    it should not take any time at all.

     

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply