Answer the question
In order to leave comments, you need to log in
MS SQL how to update schema with minimal service stop?
Azure has a database with a performance of 100 dtu in which there is a table with ~ 100 million rows. You need to change the schema of this table. Stopping the service and updating the scheme in the forehead takes ~ 2 hours. How can I reduce schema update time? What techniques are used to update the schema on the fly?
Answer the question
In order to leave comments, you need to log in
What does AZURE support say?
updating the scheme in the forehead takes ~ 2 hoursAdding a field via
ALTER TABLE
ADD
takes little time. Therefore, it is faster to add a field and transfer data than to recreate a table with data transfer. I.eALTER TABLE [Table] ADD [ColumnTemp] DECIMAL (21,8)
GO
UPDATE [Table] SET [ColumnTemp] = [Column]
GO
ALTER TABLE [Table] DROP COLUMN [Column]
GO
ALTER TABLE [Table] ADD [Column] DECIMAL (21,8)
GO
UPDATE [Table] SET [Column] = [ColumnTemp]
GO
ALTER TABLE [Table] DROP COLUMN [ColumnTemp]
GO
Should be faster. ALTER TABLE [Table] ADD [ColumnTemp] DECIMAL (21,8)
GO
UPDATE [Table] SET [ColumnTemp] = [Column]
GO
ALTER TABLE [Table] DROP COLUMN [Column]
GO
EXEC sp_rename '[Table].[ColumnTemp]' '[Column]' 'COLUMN'
GO
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question