SQLServer DBA常見問題

In the latest installment of the SQL Server interview questions, we will outline questions suitable for a DBA interview to assess the candidates skills related to SQL Server system databases. In this tip, the questions are there to read, but the answers are intentionally hidden to really test your skills. Once you read the question and have determined your answer, then highlight the answer to see how you did.

Solution

Question Difficulty = Easy

Question 1: What are the SQL Server system databases and can you outline the general functionality of each database?
Master - Database responsible for SQL Server instance related data. You can also think of this database corresponding to the Windows SQL Server service account.
Resource - Database responsible for SQL Server system objects. This database was introduced in SQL Server 2005 and is intended to ease the upgrade and rollback of SQL Server system objects.
Model - Template database for the creation of new user defined databases.
MSDB - Database responsible for SQL Server Agent related data such as Jobs, Alerts, Operators, etc.
TempDB - Temporary database to store temporary tables (#temptable or ##temptale), table variables, cursors, work tables, row versioning, create or rebuild indexes sorted in TempDB, etc. Each time the SQL Server instance is restarted all objects in this database are destroyed, so permanent objects cannot be created in this database.
Distribution - Database responsible for managing replicated data. This database could reside on the publisher or subscriber.
Additional information: SQL Server 2005 Books Online - System Databases
Question 2: True or False - Can you create objects in the Master, Model and MSDB databases?
True.
Question 3: Is it a good idea to create objects in the system databases?
In general , objects should not be created in the system databases. In general, it is a best practice to create a separate database for user defined objects that would be used instance wide or create the objects in each of the needed databases. From a DBA perspective, it is a common practice to create a dedicated DBA database in order to perform custom administrative tasks.
If objects are needed for future user defined databases those can be created in the Model database.
Question 4: Does Reporting Services create system databases during the installation process?
Yes. The databases are:
ReportServer - Stores the reports related data.
ReportServerTempDB - Temporary database storage for Reporting Services.
Additional Information: Report Server Database
Question 5: Can you move system databases?
Yes - Here are the key commands:
Master - Configuration changes with a stop and restart to the SQL Server instance.
Model - sp_detach_db and sp_attach_db
MSDB - sp_detach_db and sp_attach_db
TempDB - ALTER DATABASE command
Additional Information: How to move SQL Server databases to a new location by using Detach and Attach functions in SQL Server
Question Difficulty = Moderate

Question 1: Do users need explicit rights to the user defined databases?
No - Rights are granted through the Public Role and Guest user.
Additional Information: Guest User Account
Question 2: What are the typical objects that are created in the TempDB database?
Temporary tables (#temptable or ##temptale)
Table variables
Cursors
Work tables
Row versioning
Create or rebuild indexes sorted in TempDB
Additional information: Properly Sizing the TempDB Database
Question 3: If the model database has the database recovery model set to full, what is the impact?
When new user defined databases are created, they will have a full recovery model. This means that transaction log backups will be needed to maintain a reasonably sized transaction log. If not the transaction logs will continue to grow indefinitely.
Additional information: How to determine transaction log use
Question 4: Are all DTS packages stored in MSDB? Are all SSIS Packages stored in MSDB?
All DTS packages do not need to be stored in the MSDB database, but that was the trend in SQL Server 2000.
All SSIS Packages do not need to be stored in the MSDB database. Storage on the file system or in the MSDB database are more a matter of preference as opposed to an industry trend thus far.
Additional information: MSSQLTips.com Category - Data Transformation Services
Additional information: MSSQLTips.com Category - SQL Server Integration Services
Question 5: Does the size of the TempDB database really make a difference and how should TempDB be sized?
In situations where temporary objects are created in T-SQL code (i.e. temporary tables (#temptable or ##temptale), table variables, cursors, work tables, row versioning, create or rebuild indexes sorted in TempDB, etc.) the TempDB database makes a significant difference in overall performance. In these situations the database should be sized appropriately and moved to a separate disk drive in order to support the IO requests. If not, the default location and size may be appriopriate.
In situations where TempDB is not used in the applications, then
Additional information: Properly Sizing the TempDB Database
Question Difficulty = Advanced

Question 1: Are all SQL Server Agent configurations stored in the MSDB database?
No - Some of the configurations are stored in the registry.
Additional information: Missing SQL Server Agent History
Question 2: Please explain the relationship between logins and users in the system and user databases.
Logins - All logins reside in the master database
Users - All users reside in the master database, other system databases and in the user defined databases.
Additional information: MSSQLTips.com Category - Security
Additional information: MSSQLTips.com Category - Compliance
Question 3: With the upgrade from SQL Server 2000 to SQL Server 2005, the system objects changed. Can you name three of the mapped objects between the two versions of SQL Server?
Here are three examples, but others do exist:
System databases
SQL Server 2000 - master.dbo.sysdatabases
SQL Server 2005 - master.sys.databases
Database files
SQL Server 2000 - master.dbo.sysaltfiles
SQL Server 2005 - master.sys.master_files
IO Statistics
SQL Server 2000 - fn_virtualfilestats
SQL Server 2005 - sys.dm_io_virtual_file_stats
Additional information: Sources for Database Information - SQL Server 2000 to 2005 Crosswalk
Question 4: Can you explain the differences in restoring the Master database versus a user defined database?
In order to restore the Master database the SQL Server instance must be in single user mode.
After the Master database is restored, the SQL Server instance restarts.
A different set of restore errors may occur as compared to user defined databases. One example is if different databases exist from the backup to the current time period, errors will be recorded related to suspect databases.
Additional information: SQL Server 2005 Books Online - Restoring the master Database
Question 5: What is the Resource database and in what version of SQL Server was it introduced?
The Resource database is responsible for physically storing all of the SQL Server 2005 system objects. This database has been created to improve the upgrade and rollback of SQL Server system objects with the ability to overwrite only this database.
The Resource database was introduced in SQL Server 2005.
Additional information: SQL Server 2005 Resource Database Values in Dynamic Management Views/Functions
Additional information: SQL Server 2005 Books Online - Resource Database
Next Steps

As you prepare for an interview, consider the interview tips on MSSQLTips.com.
Check out these related tips:
MSSQLTips.com category - Interviews
MSSQLTips.com category - Professional Development
If you have a real stumper of a question, feel free to post it out to the forum listed below.
Forum Posts
To post comments about this tip click here: http://blogs.mssqltips.com/forums/t/128.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值