Changing char (8) to char (32) in SQL Server

We have a table T that contains several columns of char(8) (implicitly), which under certain conditions should be replaced with something like char(64) .

We don’t want to waste space, so this is the question: Is it an expensive operation from the computational point of view of an RDBMS (extension of the data type of columns)? We would like this to theoretically answer, no tests. Because of this, is a database needed to change the physical layout of a table?

+4
source share
2 answers

Yes, it’s quite expensive - every row in this table needs to be affected, modified, saved again, and all non-clustered indexes using any of these columns will need to be rebuilt.

Since it is CHAR(x) , it is fixed-width - so changing its size causes each individual column to be resized. In addition: when changing from 8 to 64 characters, it is likely that some pages will no longer be able to hold all lines, and a page with all their service data will be broken.

+4
source

If you increase the length of the char data type, then separation of the data pages will be required, and this will be expensive in terms of CPU usage and memory optimization and data compression.

+2
source

All Articles