Sqlserver-dba.com

Subscribe

SQLServer-DBA.com Links

Subscribe to newsletter

Dba_db2_button

Powered by TypePad
Make a database read only – READ_ONLY

13 February,2013 by Jack Vamvas

If there’s a requirement to not change data on a SQL Server database , a DBA may  make a database read only (READ_ONLY).   There are some benefits  to making a database read only outlined below.

Some notes on READ_ONLY

 1)    A small performance gain is possible due to no locking , which leads to no blocking. Read more on SQL Server - How to detect and troubleshoot blocking and deadlocks

2)    No  schema changes or data changes are possible for the duration of the database read only status

3)    Consider running optimization processes , such as full UPDATE STATISTICS and eliminate logical fragmentation before changing the status to read only . Check SQL Server Update Statistics with FULL SCAN - SQL Server DBA

 

 --to check the current status 
SELECT name, is_read_only 
FROM sys.databases 
WHERE name = 'database_name'

--to make a SQL Server database read only 
ALTER DATABASE database_name SET READ_ONLY
--to make a SQL Server database read-write
ALTER DATABASE database_name SET READ_WRITE

 Read More

SQL Database Status with sys.databases - SQL Server DBA

SQL Server – read only database status - SQL Server DBA

SQL Server DBA Scripts


Author: Jack Vamvas (http://www.sqlserver-dba.com)

******** *******

Enjoy this post? Enter your email address for updates on new posts:

Delivered by FeedBurner

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer