14261_4 SQL Server 2008 Databses

Embed Size (px)

Citation preview

  • 8/3/2019 14261_4 SQL Server 2008 Databses

    1/13

    SQL Server 2008 Databases

  • 8/3/2019 14261_4 SQL Server 2008 Databses

    2/13

    Types of databases

    1. System Databases: used to store system wide

    data and metadata.

    2. User Databases: Created by users who havethe appropriate level ofpermissions to store

    application data.

  • 8/3/2019 14261_4 SQL Server 2008 Databses

    3/13

    System Databases

    System database Description

    master Database Records all the system-level information for an instance of SQL

    Server.

    msdb Database Is used by SQL Server Agent for scheduling alerts and jobs.

    model Database Is used as the template for all databases created on the instance of

    SQL Server. Modifications made to the model database, such as

    database size, collation, recovery model, and other database

    options, are applied to any databases created afterward.

    Resource Database Is a read-only database that contains system objects that are

    included with SQL Server. System objects are physicallypersisted in

    the Resource database, but they logically appear in the sys schemaof every database.

    tempdb Database Is a workspace for holding temporary objects or intermediate result

    sets.

  • 8/3/2019 14261_4 SQL Server 2008 Databses

    4/13

    Master Database

    The master database records all the system-levelinformation for a SQL Server system. This includes instance-wide metadata such as logon accounts, endpoints, linkedservers, and system configuration settings.

    master is the database that records the existence of allother databases and the location of those database filesand records the initialization information for SQL Server.Therefore, SQL Server cannot start if the master database isunavailable.

    In SQL Server, system objects are no longer stored inthe masterdatabase; instead, they are stored inthe Resource database.

  • 8/3/2019 14261_4 SQL Server 2008 Databses

    5/13

    Model Database

    The model database is used as the template for alldatabases created on an instance of SQL Server.Because tempdb is created every time SQL Server isstarted, the modeldatabase must always exist on a SQL

    Server system. When a CREATE DATABASE statement is issued, the first

    part of the database is created by copying in the contentsof the model database. The rest of the new database isthen filled with emptypages.

    Ifyou modify the model database, all databases createdafterward will inherit those changes. For example, youcould set permissions or database options, or add objectssuch as tables, functions, or stored procedures.

  • 8/3/2019 14261_4 SQL Server 2008 Databses

    6/13

    MSDB Database

    It is considered as the sql server agents databaseas it is responsible for all automated andscheduled operations(i.e. used extensively for the

    storage of automated job definitions, jobschedules, operator definitions, and alertdefinitions)

    It is also used by service broker, database mail,

    Reporting services. For storage of SSIS packages ,it is also used by

    integration services

  • 8/3/2019 14261_4 SQL Server 2008 Databses

    7/13

    tempdb database

    The tempdb system database is a global resource that isavailable to all users connected to the instance of SQLServer Operations

    tempdb is re-created every time SQL Server is started so

    that the system always starts with a clean copy of thedatabase.

    Temporary tables and stored procedures are droppedautomatically on disconnect, and no connections are activewhen the system is shut down.

    Backup and restore operations are not allowed on tempdb.

    The size oftempdb can affect the performance of a system.overhead with the growing database can be avoided byincreasing the size oftempdb.

  • 8/3/2019 14261_4 SQL Server 2008 Databses

    8/13

    Used by sql server to store temporary objects(i.e.temporary tables, views,cursors and table valuedvariables)

    Stores work tables containing intermediate results of aqueryprior to a sort opeartion or any other

    manipulation(sorting operation would be performed in itand return sorted results)

    Used to support connection options.

    It used to hold the following: Temporary user objects that are explicitly created i.e. temp

    tables, stored procedures, variables, or cursors. Internal objects that are created by the SQL Server Database

    Engine, for example, work tables to store intermediate resultsfor spools or sorting.

    Etc

  • 8/3/2019 14261_4 SQL Server 2008 Databses

    9/13

    Resource Database

    The Resource database is a read-only database that contains all thesystem objects that are included with SQL Server.

    SQL Server system objects, such as sys.objects, are physicallypersisted in the Resource database, but they logically appear in thesys schema of every database.

    The Resource database does not contain user data or usermetadata.

    The Resource database makes upgrading to a new version of SQLServer an easier and faster procedure.

    In earlier versions of SQL Server, upgrading required dropping and

    creating system objects. Because the Resource database filecontains all system objects, an upgrade is now accomplished simplyby copying the single Resource database file to the local server.

    It is not accessible during normal database operations.

  • 8/3/2019 14261_4 SQL Server 2008 Databses

    10/13

    The physical file names of the Resource database aremssqlsystemresource.mdf and mssqlsystemresource.ldf. These filesare located in :\Program Files\Microsoft SQLserver\MSSQL10_50.\MSSQL\Binn\. Each instanceof SQL Server has one and only one associatedmssqlsystemresource.mdf file, and instances do not share this file.

    SQL Server cannot back up the Resource database.

    The Resource database should only be modified by or at thedirection of a Microsoft Customer Support Services (CSS) specialist.

    The ID of the Resource database is always 32767.

    Other important values associated with the Resource database arethe version number and the last time that the database wasupdated.

  • 8/3/2019 14261_4 SQL Server 2008 Databses

    11/13

    Distribution Databases

    It stores metadata and transactional history tosupport all types of replication on a SQL server

    One database distribution is sufficient.However if

    needed,multiple distribution databases can beconfigured.

    A model distribution database is installed bydefault and is used in the creation of a

    distribution database used in replication.

    It is installed in the same location as the rest ofthe system databases and is named distmdl.mdf

  • 8/3/2019 14261_4 SQL Server 2008 Databses

    12/13

    SQL Server 2008 Database Storage

    Two files to store all system and user

    databases(including the resource db)-

    Data File (Default extension is .mdf)

    Transaction log file(Default extension is .ldf)

    The default location for the system db files is

    :\Program Files\Microsoft SQL

    Server\MSSQL.X\MSSQL\Datahere x is the instance number

    Only developer can manipulate system databases

  • 8/3/2019 14261_4 SQL Server 2008 Databses

    13/13