Over the few months i have been playing with SQL Server 2016 new features. Microsoft SQL Server 2016 introduced new alter column with ONLINE option. Let’s explore this.
- Create a table and insert data
CREATE TABLE dbo.test_online (column_1 INT ) ;
GO
INSERT INTO dbo.test_online(column_1) values(10)
GO
- Find what page has been allocated for the above operation. I have used un documented function fn_PhysLocCracker to get the information
SELECT fnph.page_id FROM dbo.test_online
OUTER APPLY sys.fn_PhysLocCracker(%%PhysLoc%%) AS fnph;

- Perform alter column without online option
ALTER TABLE dbo.test_online
ALTER COLUMN column_1 DECIMAL (5, 2)
--WITH (ONLINE = ON);
GO
- Verify what page has been allocated for the above alter column

- You can see in the above screenshot that same page has been allocated for alter command.
- Now, let’s Perform alter column with online option. Repeat the above steps
ALTER TABLE dbo.test_online
ALTER COLUMN column_1 DECIMAL (5, 2)
WITH (ONLINE = ON);
GO
- Now verify the allocated page for the above alter command

- You can see in the above screenshot that the new page has been allocated for alter column statement without changing the old page id. This means leaving the old page available during the operation.
Conclusion: Online operation on alter column is really useful feature for DBA’s to perform the alter table with minimal downtime during the operation especially with table with large data.
Hope you like the post!
Happy Learning!
Cheers
Ramasankar Molleti
MSDN:LinkedIn:Twitter
Published by Ramasankar
As a Principal Cloud Architect with over 18 years of experience, I am dedicated to revolutionizing IT landscapes through cutting-edge cloud solutions. My expertise spans Cloud Architecture, Security Architecture, Solution Design, Cloud Migration, Database Transformation, Development, and Big Data Analytics.Currently, I spearhead cloud initiatives with a focus on Infrastructure, Containerization, Security, Big Data, Machine Learning, and Artificial Intelligence. I collaborate closely with development teams to architect, build, and manage robust cloud ecosystems that drive business growth and technological advancement.Core Competencies:
• Cloud Platforms: AWS, Google Cloud Platform, Microsoft Azure
• Technologies: Kubernetes, Serverless Computing, Microservices
• Databases: MS SQL Server, PostgreSQL, Oracle, MongoDB, Amazon Redshift, DynamoDB, Aurora
• Industries: Finance, Retail, Manufacturing.
Throughout my career, I’ve had the privilege of working with industry leaders such as OCC, Gate Gourmet, Walgreens, and Johnson Controls, gaining invaluable insights across diverse sectors.As a lifelong learner and knowledge sharer, I take pride in being the first in my organization to complete all major AWS certifications. I am passionate about mentoring and guiding fellow professionals in their cloud journey, fostering a culture of continuous learning and innovation.Let’s connect and explore how we can leverage cloud technologies to transform your business:
• LinkedIn: https://www.linkedin.com/in/ramasankar-molleti-23b13218/
• Book a mentorship session: [1:1] Together, let’s architect the future of cloud computing and drive technological excellence.
Disclaimer
The views expressed on this website/blog are mine alone and do not reflect the views of my company. All postings on this blog are provided “AS IS” with no warranties, and confers no rights. The owner of https://ramasankarmolleti.com will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of this information.
View more posts