SQL SERVER – Making Filegroup Read Only

A filegroup read-only setting prevents writes to objects stored there. A customer asked whether a table could be protected this way.

A broad compartment retaining bar protects several stored objects together.

SELECT name,is_read_only,is_default FROM sys.filegroups;
-- Reviewed secondary filegroup template, not PRIMARY:
-- ALTER DATABASE [YourDatabase] MODIFY FILEGROUP [YourFilegroup] READONLY;
-- Approved reversal:
-- ALTER DATABASE [YourDatabase] MODIFY FILEGROUP [YourFilegroup] READWRITE;

The scope covers the filegroup rather than one table. Other tables, indexes, large objects and partitions there can be affected. PRIMARY can’t be made read-only this way. Check documented requirements for the intended secondary filegroup.

Inspect allocation placement and workload before changing it. A table can have indexes or partitions on different filegroups. The change can wait on locks or disrupt required writes.

Permissions can better express an access-control requirement. The READONLY, READWRITE and SSMS options remain administrative choices. Validate a planned change and document its reversal.

Reference: Filegroup read-only requirements.

Related reading

A filegroup restriction is not a single-table permission, it is a storage-level change affecting all relevant allocations.

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

SQL Data Storage, SQL Scripts, SQL Server
Previous Post
Counting Objects by Type in Every Database With One Query
Next Post
Freeze a Table With a Read Only Filegroup in SQL Server

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.