SQL Sample Database

SQL Sample Database

 

SQL Sample Database



Summary: in this tutorial, you will learn about a SQL Sample Database called HR that manages the HR data of small businesses.

The following database diagram illustrates the HR sample database:

The HR sample database has seven tables:

  1. The employees the table stores the data of employees.
  2. The jobs the table stores the job data including job title and salary range.
  3. The departments table stores department data.
  4. The dependents the table stores the employee’s dependents.
  5. The locations table stores the location of the departments of the company.
  6. The countries the table stores the data of countries where the company is doing business.
  7. The regions table stores the data of regions such as Asia, Europe, America, and the Middle East, and Africa. The countries are grouped into regions.

The following picture shows the table names and their records.

TableRows
employees40
dependents30
departments11
jobs11
locations7
countries25
regions4

Typically, you need to install a Relational Database Management System (RDBMS) to work with SQL.

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.

In case you don’t have a database system to practice, you can quickly use our SQL online tool to execute the SQL statements in your web browser.

MySQL

The following SQL script creates the HR sample database in MySQL:

Create HR Sample Database in MySQL

The following script allows you to insert data into the tables in MySQL:

Load HR Data in MySQL

PostgreSQL

The following script creates the HR sample database structure in PostgreSQL.

Create HR Sample Database in PostgreSQL

The following script allows you to insert data into the tables in PostgreSQL:

Load HR Data in PostgreSQL

Microsoft SQL Server

The following script creates the HR sample database structure in Microsoft SQL Server.

Create HR Sample Database in SQL Server

The following script allows you to insert data into the tables:

Load HR Data in SQL Server

Oracle Database (>12c)

The following script creates the HR sample database structure in Oracle Database 12c.

Create HR Sample Database in Oracle

The following script inserts data into the tables in the Oracle database:

Load HR Data in Oracle Database

SQLite

The following script creates the HR sample database structure in SQLite.

Create HR Sample Database in SQLite

The following script inserts data into the tables in the SQLite:

Create HR Sample Database in SQLite

Removing tables

The following is the script that drops all tables in case you want to refresh the sample database.

Drop All Tables
Reactions

Post a Comment

0 Comments

close