{"id":3009,"date":"2022-03-31T10:46:20","date_gmt":"2022-03-31T03:46:20","guid":{"rendered":"https:\/\/www.sqlservertutorial.net\/?page_id=3009"},"modified":"2022-03-31T15:39:59","modified_gmt":"2022-03-31T08:39:59","slug":"sql-server-system-databases","status":"publish","type":"page","link":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-system-databases\/","title":{"rendered":"SQL Server System Databases"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you&#8217;ll learn about the SQL Server system databases and their purposes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='introduction-to-the-sql-server-system-databases'>Introduction to the SQL Server system databases <a href=\"#introduction-to-the-sql-server-system-databases\" class=\"anchor\" id=\"introduction-to-the-sql-server-system-databases\" title=\"Anchor for Introduction to the SQL Server system databases\">#<\/a><\/h2>\n\n\n\n<p>By default, SQL Server provides you with four main systems databases:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>master<\/li><li>msdb<\/li><li>model<\/li><li>tempdb<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id='master'>master <a href=\"#master\" class=\"anchor\" id=\"master\" title=\"Anchor for master\">#<\/a><\/h3>\n\n\n\n<p>The <code>master<\/code> database stores all the system-level information of an SQL Server instance, which includes:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Server configuration settings<\/li><li>Logon accounts<\/li><li>Linked servers information <\/li><li>Startup stored procedure<\/li><li>File locations of user databases<\/li><\/ul>\n\n\n\n<p>If the <code>master<\/code> database is unavailable, the SQL Server cannot start. When you work with the <code>master<\/code> database, you should:<\/p>\n\n\n\n<p>First, always have a current backup of the <code>master<\/code> database. If the <code>master<\/code> database is corrupted, you can restore it from the backup.<\/p>\n\n\n\n<p>Second, back up the <code>master<\/code> database as soon as possible after the following operations:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-create-database\/\">Creating<\/a>, modifying, and <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-drop-database\/\">dropping<\/a> any database<\/li><li>Changing the server configurations<\/li><li>Update the logon accounts including adding, removing, and modifying<\/li><\/ul>\n\n\n\n<p>Third, do not create user objects in the <code>master<\/code> database.<\/p>\n\n\n\n<p>Finally, do not set the <code>TRUSTWORTHY<\/code> database property of the master to <code>ON<\/code>. <\/p>\n\n\n\n<p>Note that if the <code>TRUSTWORTHY<\/code> database property is <code>ON<\/code>, the SQL Server will trust the database and the contents within it, which increases the security risk.  By default, the <code>TRUSTWORTHY<\/code> is <code>OFF<\/code>. <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/relational-databases\/security\/trustworthy-database-property\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">More information on the TRUSTWORTHY option.<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='msdb'>msdb <a href=\"#msdb\" class=\"anchor\" id=\"msdb\" title=\"Anchor for msdb\">#<\/a><\/h3>\n\n\n\n<p>The <code>msdb<\/code> is used by the SQL Server Agent for scheduling jobs and alerts. Also, it stores the history of the SQL Agent jobs.<\/p>\n\n\n\n<p>The <code>msdb<\/code> supports the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Jobs &amp; alerts<\/li><li>Database Mail<\/li><li>Service Broker<\/li><li>And the backup &amp; restore history for the databases<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id='model'>model <a href=\"#model\" class=\"anchor\" id=\"model\" title=\"Anchor for model\">#<\/a><\/h3>\n\n\n\n<p>SQL Server uses the <code>model<\/code> database as the template for creating other databases. <\/p>\n\n\n\n<p>When you <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-create-database\/\">create a new database<\/a>, SQL Server copies the contents of the <code>model<\/code> database including database options to the new database. <\/p>\n\n\n\n<p>If you modify the <code>model<\/code> database, all databases that you create afterward will take these changes.<\/p>\n\n\n\n<p>Whenever SQL Server starts, it creates the <code>tempdb<\/code> from the <code>model<\/code> database. Therefore, the <code>model<\/code> database must always exist on the SQL Server.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id='tempdb'>tempdb <a href=\"#tempdb\" class=\"anchor\" id=\"tempdb\" title=\"Anchor for tempdb\">#<\/a><\/h3>\n\n\n\n<p>The <code>tempdb<\/code> database stores temporary user objects that you explicitly create like <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-temporary-tables\/\">temporary tables<\/a> and <a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-user-defined-functions\/sql-server-table-variables\/\">table variables<\/a>.<\/p>\n\n\n\n<p>Also, the <code>tempdb<\/code> stores the internal objects that the database engine creates. For example, the <code>tempdb<\/code> database stores the immediate sort results for running the queries that include the <code><a href=\"https:\/\/www.sqlservertutorial.net\/sql-server-basics\/sql-server-order-by\/\">ORDER BY<\/a><\/code> clause.<\/p>\n\n\n\n<p>SQL Server recreates the <code>tempdb<\/code> database every time it starts. Since the <code>tempdb<\/code> is non-permanent storage, you cannot back it up or restore it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='summary'>Summary <a href=\"#summary\" class=\"anchor\" id=\"summary\" title=\"Anchor for Summary\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>SQL Server provides four system databases including <code>master<\/code>, <code>msdb<\/code>, <code>model<\/code>, and <code>tempdb<\/code>.<\/li><li>The <code>master<\/code> system database stores system-level information of the SQL server instance.<\/li><li>The <code>msdb<\/code> database is used by SQL Server Agent for jobs &amp; alerts.<\/li><li>The <code>model<\/code> database is served as a template for creating other databases.<\/li><li>The <code>tempdb<\/code> system database stores the temporary objects and is recreated every time the SQL Server starts.<\/li><\/ul>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"3009\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-system-databases\/\"\n\t\t\t\tdata-post-title=\"SQL Server System Databases\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"3009\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-system-databases\/\"\n\t\t\t\tdata-post-title=\"SQL Server System Databases\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you&#8217;ll learn about the SQL Server system databases and their purposes.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":2903,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-3009","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SQL Server System Databases<\/title>\n<meta name=\"description\" content=\"In this tutorial, you&#039;ll learn about the SQL Server system databases and their purposes.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-system-databases\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Server System Databases\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you&#039;ll learn about the SQL Server system databases and their purposes.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-system-databases\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Server Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2022-03-31T08:39:59+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-system-databases\\\/\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-system-databases\\\/\",\"name\":\"SQL Server System Databases\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\"},\"datePublished\":\"2022-03-31T03:46:20+00:00\",\"dateModified\":\"2022-03-31T08:39:59+00:00\",\"description\":\"In this tutorial, you'll learn about the SQL Server system databases and their purposes.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-system-databases\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-system-databases\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/sql-server-system-databases\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Server Administration\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/sql-server-administration\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"SQL Server System Databases\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\",\"name\":\"SQL Server Tutorial\",\"description\":\"The Practical SQL Server Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SQL Server System Databases","description":"In this tutorial, you'll learn about the SQL Server system databases and their purposes.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-system-databases\/","og_locale":"en_US","og_type":"article","og_title":"SQL Server System Databases","og_description":"In this tutorial, you'll learn about the SQL Server system databases and their purposes.","og_url":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-system-databases\/","og_site_name":"SQL Server Tutorial","article_modified_time":"2022-03-31T08:39:59+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-system-databases\/","url":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-system-databases\/","name":"SQL Server System Databases","isPartOf":{"@id":"https:\/\/www.sqlservertutorial.net\/#website"},"datePublished":"2022-03-31T03:46:20+00:00","dateModified":"2022-03-31T08:39:59+00:00","description":"In this tutorial, you'll learn about the SQL Server system databases and their purposes.","breadcrumb":{"@id":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-system-databases\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-system-databases\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/sql-server-system-databases\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlservertutorial.net\/"},{"@type":"ListItem","position":2,"name":"SQL Server Administration","item":"https:\/\/www.sqlservertutorial.net\/sql-server-administration\/"},{"@type":"ListItem","position":3,"name":"SQL Server System Databases"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlservertutorial.net\/#website","url":"https:\/\/www.sqlservertutorial.net\/","name":"SQL Server Tutorial","description":"The Practical SQL Server Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlservertutorial.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/3009","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/comments?post=3009"}],"version-history":[{"count":5,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/3009\/revisions"}],"predecessor-version":[{"id":3017,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/3009\/revisions\/3017"}],"up":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/2903"}],"wp:attachment":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/media?parent=3009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}