Download Sample DB

This will generate and download code to install the SampleDB for your database. To use:

Refresh Data

Select the Sample

Select the DBMS

PostgreSQL

SQLite

MySQL / MariaDB

Microsoft SQL

Oracle

Db2

Optional: Select Additional Tables

Optional: Select Exercises

Select the Line Break

Download Script

Download

Notes

If you select a single DBMS, it will be downloaded directly. If, however, you select more than one DBMS, you will download a ZIP file with the selected files.

Generic SQL

This is a generic script using standard ANSI SQL. It should work on any normal DBMS. Note, however, that it may run slowly on SQLite.

The generic script does not include CREATE or TRUNCATE statements, as they are too vendor-specific.

PostgreSQL up to 9

The CREATE TABLE code for PostreSQL includes the the older SERIAL syntax for auto-incremented primary keys.

PostgreSQL from 10

The CREATE TABLE code for PostreSQL includes the the newer GENERATED BY DEFAULT AS IDENTITY syntax for auto-incremented primary keys.

SQLite Script

The script is in SQLite 3 format. It includes an empty SQLite File.

SQLite File

This generates a database file called sampledb.sqlite The database is in SQLite 3 format.

MySQL / MariaDB — ANSI

This is the ANSI Mode version.

The most obvious differences are that ANSI mode uses "double quotes" for Column Names, and the || operator is used for concatenation.

MySQL / MariaDB — Traditional

The is the Traditional Mode version.

The most obvious differences are that Traditional mode uses `back ticks` for Column Names, and that the || operator doesn’t concatenate.

Microsoft SQL up to 2014

Before 2016, you can’t use DROP TABLE IF EXISTS, so the CREATE script uses IF OBJECT_ID('…','U').

See notes on installing Microsoft SQL Server and setting up SSMS

Microsoft SQL from 2016

The CREATE script uses DROP TABLE IF EXISTS.

See notes on installing Microsoft SQL Server and setting up SSMS

Oracle

Prior to version 12, Oracle did not support IDENTITY columns for auto-incremented keys, so this script includes the workaround using triggers. The IDENTITY statement is commented out, so, if you want to use it, uncomment it and comment out the plain version in each CREATE TABLE statement.

The older version script will still work well enough on newer versions of Oracle.

Oracle

From version 12, Oracle supports IDENTITY columns for auto-incremented keys.

This script does not include SET DEFINE OFF;, so it may not work properly with the SQLPlus client.

Oracle

From version 12, Oracle supports IDENTITY columns for auto-incremented keys, as well as batched INSERT.

This script includes SET DEFINE OFF;, which is good for SQLPlus, but it may not work properly with other clients.

Oracle

From version 23c, Oracle supports IDENTITY columns for auto-incremented keys, as well as batched INSERT statements.

This script does not include SET DEFINE OFF;, so it may not work properly with the SQLPlus client.

Oracle

From version 23c, Oracle supports IDENTITY columns for auto-incremented keys, as well as batched INSERT statements.

This script includes SET DEFINE OFF;, which is good for SQLPlus, but it may not work properly with other clients.

Db2

Experimental Support for Db2

Tested on:

  • Db2 v12.1.1.0 LUW on Docker
  • DB2 v11.5.9.0 LUW on IBM Cloud