the fifth database - isug 101
TRANSCRIPT
The Fifth Database
Guy Twena SQL Server Consultant
Agenda
• The master database in 2000• What is The Fifth Database• Querying metadata of the Resource Database• DAC• Memory objects tables – PSS & EX• Making changes to the resource database• Backup and restore to the resource database• Moving The Resource Database• Examples• Q&A
The master database in 2000 (BC)
• Upgrading sql server 2000 required dropping system objects and recreating them
• In sql server 2000 it was very easy to make changes to the master Database
What is the fifth database
• Mssqlsystemresource - introduced in sql 2005• Read-only, contains all the system objects.• Does not contain user data or user metadata.• Easier upgrading to a new version of SQL Server • Its easier to rollback you can just replace the
ResourceDB• The id of the resource DB is 32767• The default location of the file is in the binn directoy
“MSSQL$Instance\MSSQL\binn”• It important not to put the resource database on
compressed volume
Querying metadata of the Resource Database
DAC
• DAC – Dedicated Administrator Connection• The purpose of the DAC is to allow you to connect the
server if its not responding• Only one DAC can be connected at any time• In order to connect with DAC for server with instance,
the browser service must be running• The User must be from the sysadmin server role• You can view the content of system objects in each of
the user Databases
DAC – Dedicated Administrator Connection
• In order to connect with DAC you can use the following:– Sqlcmd –A –S<server\instance>– Sqlcmd–Sadmin:<server\instance>– Sqlcmd -S<server\instance>,<DAC Port>– Using SSMS, using “New Query” .
Note: connecting DAC with “Object Explorer” will not work!!! ; You will receive the following error:“Dedicated Administrator Connection are not supported”
• In order to open the DAC Connection to remote computers,sp_configure “remote admin connections”
Memory objects tables – PSS & EX
• PSS – Process Storage Structure, – holds information about your login details, network address, last
command that run, query and query poison etc.
• EX – Execution Context – is what is passed to the CPU queue e.g:when the process is sleeping
• PSS and EX Objects are stored in array and are constantly updates as any change
Memory objects tables – PSS & EX
The table SYSSESSIONS doesn’t exists in the mdf file, you won’t be able to find its data with hex editor
Making changes to the resource database & System Tables
• Using DAC.• single user mode (-m).• still you won’t be able to see the database in sys.databases. • “use mssqlsystemresource” will change the context to the resource
database• DBCC CHECKCATALOG
Hacking The Resource Database
Backup and restore to the resource database
• SQL Server cannot back up the Resource database.
• In order to backup the resource database you need to copy the file manually
• you cannot use SQL Server to restore the resource database backups.
• Restoring a backup copy of mssqlsystemresource.mdf can only be done manually, and you must be careful not to overwrite the current Resource database with an out-of-date or potentially insecure version
Moving The Resource Database
• SQL Server 2005 – the resource database had to be in the same folder as the masterDBin order to move the resource Database we should start the SQL Server with –f;-T3608
• SQL Server 2008 – the resource Database was located in the “/binn” folder of every instance, but we could move it
• SQL Server 2008R2 the location of the resource Database is in the /Binn folder but you cann’t move it
Examples
• Viewing the sys.databases definition• Different in objects that are in the master and the
resource DB• Changing column name• Reading the content of the resource database• Drop DB• how much does your data change?• Adding new SP to the resource Database
Example - how much does your data change?
• Affects the transaction log sizes • Affects the backups Size• The load on your server• In SQL 2000 we had sysindexes.rcmodctr that
keeps track of how many rows have changed• In SQL server 2008 we have
sys.sysrscols.Rcmodified that can be viewed with the DAC Connection
Examples
• Viewing the sys.databases definition• Different in objects that are in the master and the
resource DB• Changing column name• Reading the content of the resource database• Drop DB• how much does your data change?• Adding new SP to the resource Database
Questions?
The end