Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Nakul Vachhrajani is a Technical Specialist & Systems development professional with iGATE. He holds a MCTS (SQL Server 2008: Implementation & Maintenance)
Browse by Tags · View All
#SQLServer 242
SQL Server 241
Administration 208
DBA 197
Tips 186
Development 186
T-SQL 181
#TSQL 179
Guidance 123
Tools and Utilities 112

Archive · View All
April 2011 14
March 2012 11
December 2011 11
March 2011 11
December 2012 10
October 2011 10
January 2011 10
January 2013 9
November 2012 9
October 2012 9

SQL Server Myth: Log files are removed when a database is made READ_ONLY

Aug 8 2011 12:00AM by Nakul Vachhrajani   

Today, I attempt to bust a myth related to transaction log files for read-only databases in Microsoft SQL Server. Read-only databases, as the name suggests are databases containing static data. Quite often, applications use read-only copies of 3rd party data, restored in the data-center as read-only databases. For instance, there are services that provide a universal lookup for ISO codes for currencies & countries. Countries and currency codes do not change daily, and it makes great sense to convert the databases to read-only databases.

Just recently, I read in a book something that jolted me because it was an authoritative book. The sentence goes something like:

“When a database is placed in READ_ONLY mode, SQL Server removes any transaction log file that is specified for the database.

The above statement is incorrect. What is correct is that the transaction log continues to exist – irrespective of whether or not the database is in READ_ONLY mode.

When in doubt, I always believe that a simple test should be done to confirm. So, here’s a very simple, do-it-yourself test that you can run on your test/development server:

--Step 01: Create a test database & confirm that it is not READ_ONLY
USE master
GO
CREATE DATABASE ReadOnlyTest
GO

SELECT sdb.is_read_only,
       sdb.* 
FROM sys.databases sdb 
WHERE sdb.name = 'ReadOnlyTest'

--Step 02: Confirm that the database has 2 files - one primary data file, one log file
USE ReadOnlyTest
GO
SELECT 'Before',* FROM sys.sysfiles
GO

--Step 03: Make Database READ_ONLY and confirm
USE master
GO
ALTER DATABASE ReadOnlyTest SET READ_ONLY
GO

SELECT sdb.is_read_only,
       sdb.* 
FROM sys.databases sdb 
WHERE sdb.name = 'ReadOnlyTest'

--Step 04: Confirm that the database still has 2 files - one primary data file, one log file
USE ReadOnlyTest
GO
SELECT 'After',* FROM sys.sysfiles
GO

--Step 05: Finally drop the test database as cleanup
USE master
GO
DROP DATABASE ReadOnlyTest
GO

Here’s what you would see:

image

What we know for sure is that the log files are not “removed”. Using the undocumented DBCC commands like DBCC LOGINFO and DBCC LOG, I could determine to a fair level of confidence that the log file is not used for some common read-only operations (SELECT, BACKUP).

Do you know why the transaction log file is required for READ_ONLY databases? Do let me know. I look forward eagerly to your response.

Until we meet next time,

Be courteous. Drive responsibly.

Tags: 


Nakul Vachhrajani
4 · 33% · 10680
0
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

2  Comments  

  • Hi Nakul,

    The book appears to be incorrect. Changeing DB to Readonly or Readwrite will not make logfile dissappear.

    When we set up T-log shipping we have the option to set DR db to Restore with Standby option. This option allow to restore the T-log backups also DB will be in Readonly mode.

    Think only DB snapshots will be created without the logfiles.

    Thanks,

    Shree

    commented on Aug 19 2011 3:24AM
    hshripati
    638 · 0% · 53
  • Hello,

    According to Kaleen Delaney in her book "Inside Microsoft SQL Server 2005 : The Storage Engine The READWRITE/READONLY options describe the updatabilty of the database.In READONLY mode, no INSERT,UPDATE or DELETE operations can be executed.;Because no modifications are done when a database is in READONLY mode, automatic recovery is not run on this database when SQL Server is restarted and no locks need to be required during any SELECT operations, moreover shrinking the database is not possible". So , i think there only only an error , "removed" should be replaced by "not used". If any of yours is a 2011 MCC, i would suggest him to have a look at Safari ONLINE.He/she should be able to read the pdf of the same book for SQL Server 2008.

    Have a nice day

    commented on Aug 19 2011 6:43AM
    Patrick Lambin
    163 · 1% · 296

Your Comment


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]