系统数据库和数据库文件

1. 系统数据库:

对于数据库实例来说,系统数据库是默认数据库,在我们装好数据库时它们就是存在的。系统数据库有:master,model,msdb,tempdb以及Resource数据库。

master数据库存储着服务器配置信息,初始化信息,实例中所有数据库的信息;model数据库是一个数据库模板,所有用户数据库都是以model数据库为模板建立; tempdb数据库用于存储临时数据,每次数据库实例重启时都将以model数据库为模板重新创建tempdb数据库。

  • master The master database holds instance-wide metadata information, server configuration, information about all databases in the instance, and initialization information.

  • Resource The Resource database was added as of SQL Server 2005 and it holds all system objects. When you query metadata information in a database, this information appears to be local to the database but in practice it resides in the Resource database.

  • model The model database is used as a template for new databases. Every new database that you create is initially created as a copy of model. So if you want certain objects (such as data types) to appear in all new databases that you create, or certain database properties to be configured in a certain way in all new databases, you need to create those objects and configure those properties in the model database. Note that changes you apply to the model database will not impact existing databases—only new databases that you create in the future.

  • tempdb The tempdb database is where SQL Server stores temporary data such as work tables, sort space, row versioning information, and so on. SQL Server allows you to create temporary tables for your own use, and the physical location of those temporary tables is tempdb. Note that this database is destroyed and recreated as a copy of the model every time you restart the instance of SQL Server. For this reason, when I need to create objects for test purposes and I don't want the objects to remain in the database, I usually create them in tempdb. I know that even if I forget to clear those objects, they will be automatically cleared after restart.

  • msdb The msdb database is where a service called SQL Server Agent stores its data. SQL Server Agent is in charge of automation, which includes entities such as jobs, schedules, and alerts. The SQL Server Agent is also the service in charge of replication. The msdb database also holds information related to other SQL Server features such as Database Mail and Service Broker.

2. 数据库文件:

数据库由数据文件和事务日志文件组成,主数据文件(master data file)的扩展名为.mdf;日志数据文件(log data file)的扩展名为.ldf;从数据文件(secondary data file)扩展名为.ndf(not master data file).

原文地址:https://www.cnblogs.com/ITGirlXiaoXiao/p/2269127.html