{"id":2068,"date":"2020-04-05T19:17:34","date_gmt":"2020-04-06T02:17:34","guid":{"rendered":"https:\/\/sqltutorial.org\/?page_id=2068"},"modified":"2020-04-05T19:54:44","modified_gmt":"2020-04-06T02:54:44","slug":"sql-sample-database","status":"publish","type":"page","link":"https:\/\/www.sqltutorial.org\/sql-sample-database\/","title":{"rendered":"SQL Sample Database"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn about a SQL Sample Database called HR that manages the HR data of the small businesses.<\/p>\n\n\n\n<p>The following database diagram illustrates the HR sample database:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"704\" height=\"561\" src=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/04\/SQL-Sample-Database-Schema.png\" alt=\"SQL Sample Database Schema\" class=\"wp-image-605\" title=\"SQL Sample Database\" srcset=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/04\/SQL-Sample-Database-Schema.png 704w, https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/04\/SQL-Sample-Database-Schema-300x239.png 300w\" sizes=\"auto, (max-width: 704px) 100vw, 704px\" \/><\/figure>\n\n\n\n<p>The HR sample database has seven tables:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>The <code>employees<\/code> table stores the data of employees.<\/li><li>The <code>jobs<\/code> table stores the job data including job title and salary range.<\/li><li>The <code>departments<\/code>\u00a0table stores department data.<\/li><li>The <code>dependents<\/code> table stores the employee&#8217;s dependents.<\/li><li>The <code>locations<\/code> table stores the location of the departments of the company.<\/li><li>The <code>countries<\/code> table stores the data of countries where the company is doing business.<\/li><li>The <code>regions<\/code> table stores the data of regions such as Asia, Europe, America, and\u00a0the Middle East and Africa. The countries are grouped into regions.<\/li><\/ol>\n\n\n\n<p>The following picture shows the table names and their records.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Table<\/th><th>Rows<\/th><\/tr><\/thead><tbody><tr><td>employees<\/td><td>40<\/td><\/tr><tr><td>dependents<\/td><td>30<\/td><\/tr><tr><td>departments<\/td><td>11<\/td><\/tr><tr><td>jobs<\/td><td>11<\/td><\/tr><tr><td>locations<\/td><td>7<\/td><\/tr><tr><td>countries<\/td><td>25<\/td><\/tr><tr><td>regions<\/td><td>4<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Typically, you need to install a Relational Database Management System (RDBMS) to work with SQL.<\/p>\n\n\n\n<p>If you have worked with an RDBMS such as MySQL, PostgreSQL, Oracle Database, and SQL Server, you can use the following script to create the sample database in one of these databases.<\/p>\n\n\n\n<p>In case you don&#8217;t have a database system to practice, you can quickly use our <a href=\"https:\/\/www.sqltutorial.org\/seeit\/\">SQL online tool to execute the SQL statements in your web browser.<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='mysql'>MySQL <a href=\"#mysql\" class=\"anchor\" id=\"mysql\" title=\"Anchor for MySQL\">#<\/a><\/h2>\n\n\n\n<p>The following SQL script creates the HR sample database in MySQL:<\/p>\n\n\n\n<a class=\"buttonDownload\" href=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2020\/04\/mysql.txt\">Create HR Sample Database in MySQL<\/a>\n\n\n\n<p>The following script allows you to insert data into the tables in MySQL:<\/p>\n\n\n\n<a class=\"buttonDownload\" href=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2020\/04\/mysql-data.txt\">Load HR Data in MySQL<\/a>\n\n\n\n<h2 class=\"wp-block-heading\" id='postgresql'>PostgreSQL <a href=\"#postgresql\" class=\"anchor\" id=\"postgresql\" title=\"Anchor for PostgreSQL\">#<\/a><\/h2>\n\n\n\n<p>The following script creates the HR sample database structure in PostgreSQL.<\/p>\n\n\n\n<a class=\"buttonDownload\" href=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2020\/04\/postgresql.txt\">Create HR Sample Database in PostgreSQL<\/a>\n\n\n\n<p>The following script allows you to insert data into the tables in PostgreSQL:<\/p>\n\n\n\n<a class=\"buttonDownload\" href=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2020\/04\/postgresql-data.txt\">Load HR Data in PostgreSQL<\/a>\n\n\n\n<h2 class=\"wp-block-heading\" id='microsoft-sql-server'>Microsoft SQL Server <a href=\"#microsoft-sql-server\" class=\"anchor\" id=\"microsoft-sql-server\" title=\"Anchor for Microsoft SQL Server\">#<\/a><\/h2>\n\n\n\n<p>The following script creates the HR sample database structure in Microsoft SQL Server.<\/p>\n\n\n\n<a class=\"buttonDownload\" href=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2020\/04\/sqlserver.txt\">Create HR Sample Database in SQL Server<\/a>\n\n\n\n<p>The following script allows you to insert data into the tables:<\/p>\n\n\n\n<a class=\"buttonDownload\" href=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2020\/04\/sqlserver-data.txt\">Load HR Data in SQL Server<\/a>\n\n\n\n<h2 class=\"wp-block-heading\" id='oracle-database-12c'>Oracle Database (&gt;12c) <a href=\"#oracle-database-12c\" class=\"anchor\" id=\"oracle-database-12c\" title=\"Anchor for Oracle Database (&gt;12c)\">#<\/a><\/h2>\n\n\n\n<p>The following script creates the HR sample database structure in Oracle Database 12c.<\/p>\n\n\n\n<a class=\"buttonDownload\" href=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2020\/04\/oracle.txt\">Create HR Sample Database in Oracle<\/a>\n\n\n\n<p>The following script inserts data into the tables in the Oracle database:<\/p>\n\n\n\n<a class=\"buttonDownload\" href=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2020\/04\/oracle-data.txt\">Load HR Data in Oracle Database<\/a>\n\n\n\n<h2 class=\"wp-block-heading\" id='sqlite'>SQLite <a href=\"#sqlite\" class=\"anchor\" id=\"sqlite\" title=\"Anchor for SQLite\">#<\/a><\/h2>\n\n\n\n<p>The following script creates the HR sample database structure in SQLite.<\/p>\n\n\n\n<a class=\"buttonDownload\" href=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2020\/04\/sqlite.txt\">Create HR Sample Database in SQLite<\/a>\n\n\n\n<p>The following script inserts data into the tables in the SQLite:<\/p>\n\n\n\n<a class=\"buttonDownload\" href=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2020\/04\/sqlite-data.txt\">Create HR Sample Database in SQLite<\/a>\n\n\n\n<h2 class=\"wp-block-heading\" id='removing-tables'>Removing tables <a href=\"#removing-tables\" class=\"anchor\" id=\"removing-tables\" title=\"Anchor for Removing tables\">#<\/a><\/h2>\n\n\n\n<p>The following is the script that drops all tables in case you want to refresh the sample database.<\/p>\n\n\n\n<a class=\"buttonDownload\" href=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2020\/04\/drop-tables.txt\">Drop All Tables<\/a>\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=\"2068\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqltutorial.org\/sql-sample-database\/\"\n\t\t\t\tdata-post-title=\"SQL Sample Database\"\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=\"2068\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqltutorial.org\/sql-sample-database\/\"\n\t\t\t\tdata-post-title=\"SQL Sample Database\"\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, we will introduce you to an SQL sample database that we will use in all the tutorials.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":57,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-2068","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SQL Sample Database<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will learn about the SQL sample database called HR.\" \/>\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.sqltutorial.org\/sql-sample-database\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQL Sample Database\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn about the SQL sample database called HR.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqltutorial.org\/sql-sample-database\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2020-04-06T02:54:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/04\/SQL-Sample-Database-Schema.png\" \/>\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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqltutorial.org\/sql-sample-database\/\",\"url\":\"https:\/\/www.sqltutorial.org\/sql-sample-database\/\",\"name\":\"SQL Sample Database\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqltutorial.org\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.sqltutorial.org\/sql-sample-database\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.sqltutorial.org\/sql-sample-database\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/04\/SQL-Sample-Database-Schema.png\",\"datePublished\":\"2020-04-06T02:17:34+00:00\",\"dateModified\":\"2020-04-06T02:54:44+00:00\",\"description\":\"In this tutorial, you will learn about the SQL sample database called HR.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.sqltutorial.org\/sql-sample-database\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqltutorial.org\/sql-sample-database\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqltutorial.org\/sql-sample-database\/#primaryimage\",\"url\":\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/04\/SQL-Sample-Database-Schema.png\",\"contentUrl\":\"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/04\/SQL-Sample-Database-Schema.png\",\"width\":704,\"height\":561},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqltutorial.org\/sql-sample-database\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqltutorial.org\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQL Sample Database\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqltutorial.org\/#website\",\"url\":\"https:\/\/www.sqltutorial.org\/\",\"name\":\"SQL Tutorial\",\"description\":\"An Interactive SQL Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqltutorial.org\/?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 Sample Database","description":"In this tutorial, you will learn about the SQL sample database called HR.","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.sqltutorial.org\/sql-sample-database\/","og_locale":"en_US","og_type":"article","og_title":"SQL Sample Database","og_description":"In this tutorial, you will learn about the SQL sample database called HR.","og_url":"https:\/\/www.sqltutorial.org\/sql-sample-database\/","og_site_name":"SQL Tutorial","article_modified_time":"2020-04-06T02:54:44+00:00","og_image":[{"url":"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/04\/SQL-Sample-Database-Schema.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqltutorial.org\/sql-sample-database\/","url":"https:\/\/www.sqltutorial.org\/sql-sample-database\/","name":"SQL Sample Database","isPartOf":{"@id":"https:\/\/www.sqltutorial.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqltutorial.org\/sql-sample-database\/#primaryimage"},"image":{"@id":"https:\/\/www.sqltutorial.org\/sql-sample-database\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/04\/SQL-Sample-Database-Schema.png","datePublished":"2020-04-06T02:17:34+00:00","dateModified":"2020-04-06T02:54:44+00:00","description":"In this tutorial, you will learn about the SQL sample database called HR.","breadcrumb":{"@id":"https:\/\/www.sqltutorial.org\/sql-sample-database\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqltutorial.org\/sql-sample-database\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqltutorial.org\/sql-sample-database\/#primaryimage","url":"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/04\/SQL-Sample-Database-Schema.png","contentUrl":"https:\/\/www.sqltutorial.org\/wp-content\/uploads\/2016\/04\/SQL-Sample-Database-Schema.png","width":704,"height":561},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqltutorial.org\/sql-sample-database\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqltutorial.org\/"},{"@type":"ListItem","position":2,"name":"SQL Sample Database"}]},{"@type":"WebSite","@id":"https:\/\/www.sqltutorial.org\/#website","url":"https:\/\/www.sqltutorial.org\/","name":"SQL Tutorial","description":"An Interactive SQL Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqltutorial.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/pages\/2068","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/comments?post=2068"}],"version-history":[{"count":0,"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/pages\/2068\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqltutorial.org\/wp-json\/wp\/v2\/media?parent=2068"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}