The other day, I received an email from a user, who had dropped master database in their system. I told him directly that he should have not dropped master database as that is a very important system database. It is really strange that after so many years quite a few of the people do not know what is a master database in SQL Server.
Question: What is a Master Database in SQL Server?
Answer: Master database is system database and it contains information about running server’s configuration. When SQL Server is installed, it usually creates master, model, msdb, tempdb resource and distribution (last two depends on version of SQL Server) system database by default. This is the one which is absolutely must have a database. Without this database SQL Server cannot be started.
If any database is corrupted it should be restored from the latest backup, considering SQL Server was able to start with a damaged database. Sometimes when this database is corrupted so much it cannot start SQL Server at all and it cannot be restored. SQL Server should rebuild using command prompt and restored from the latest backup once again.
If you ever lose your master database or got it corrupted you can easily fix it as well. I have documented in this link about how to fix master database.
Additionally, if your master database size ever goes big, here is interesting blog post about that subject. Additionally, you should always backup master database just like any other database.
Backup of the this database should be made for:
- Changing server-level configuration settings;
- Changing database-level configuration settings; and
- Changing any logon accounts details.
When someone talks about master database, I always think of Yoda. Here are a few interesting quotes from Yoda.
- “A Jedi uses the Force for knowledge and defense, never for attack.” The Empire Strikes Back
- “Adventure. Excitement. A Jedi craves not these things.” The Empire Strikes Back
- “Judge me by my size, do you?” The Empire Strikes Back
- “Fear is the path to the dark side…fear leads to anger…anger leads to hate…hate leads to suffering.” The Phantom Menace
- “Do. Or do not. There is no try.” The Empire Strikes Back
The last one is the most popular and my favorite quote from Yoda. Yoda also said “Always pass on what you have learned.”, well, I request you to share this blog post with your friends and you will make Yoda happy.
Reference: Pinal Dave (https://blog.sqlauthority.com)
System databases can’t be dropped. How did he do it?
Good question. I will see if I can find answer of it.
These files can be deleted manually by using Windows Explorer. To remove a database from the current server without deleting the files from the file system, use sp_detach_db.
Master files can be deleted manually by using Windows Explorer. To remove a database from the current server without deleting the files from the file system, use sp_detach_db.
Did you try deleting mdf and left files when the dub was online? Did it work?
And master database or for that matter system databases can’t be detached using sp_detach_db.