neondatabase/postgres-sample-dbs(新しいタブで開きます)
主要言語: PLpgSQL
A collection of sample Postgres databases for learning, testing, and development.
- star 数
- 266
- watcher 数
- 4
- fork 数
- 48
- issue 数
- 0
- 最終更新
- 2025/12/23
主要言語: PLpgSQL
A collection of sample Postgres databases for learning, testing, and development.
A collection of sample Postgres databases for learning, testing, and development.
Data was loaded into Neon Serverless Postgres (Postgres 15). The data was then dumped using the pg_dump utility. For example:
pg_dump "postgres://<user>:<password>@<hostname>/<dbname>" --file=[file_name].sql --format=p --no-owner --no-privilegesFor larger datasets, such as the employees database, the following format option was used: --format=c
git clone https://github.com/neondatabase-labs/postgres-sample-dbs.git
You can download an individual dump file from this repo on the GitHub site or using wget.
From this repo on the GitHub site:
Using wget:
wget https://raw.githubusercontent.com/neondatabase-labs/postgres-sample-dbs/main/<dump_file_name.sql>
These dump files use COPY ... FROM stdin for fast data loading. This command streams data through the client connection, which only works with psql:
psql -d "postgres://user:pass@host/dbname" -f filename.sqlThis won't work:
These tools don't support psql's stdin streaming protocol and will fail with errors like "No source stream defined" or syntax errors.
Need to use a GUI tool?Re-export the data with INSERT statements instead of COPY:
pg_dump --inserts dbname > dump_inserts.sqlThis is slower but works anywhere.
psql client for connecting to your Neon database and loading data. This client is included with a standalone PostgreSQL installation. See PostgreSQL Downloads.pg_restore client if you are loading the employees database. The pg_restore client is also included with a standalone PostgreSQL installation. See PostgreSQL Downloads.postgres://<user>:<password>@<hostname>/[dbname] with your Neon database connection string. For further information, see Connect from any application.psql or from the Neon SQL Editor.Sample datasets are listed in order of the smallest to largest installed size. Note that Neon's Free Tier has a storage limit of 500 MB per branch, though all databases in this repository fit within that limit.
| Name | Tables | Records | Source file size | Installed size |
|---|---|---|---|---|
| Periodic table data | 1 | 118 | 17 KB | 7.2 MB |
| World Happiness Index | 1 | 156 | 9.4 KB | 7.2 MB |
| Titanic passenger data | 1 | 1309 | 220 KB | 7.5 MB |
| Netflix data | 1 | 8807 | 3.2 MB | 11 MB |
| DVD rental tutorial database | 15 | 15861 | 2.7 MB | 14 MB |
| Pagila database | 33 | 62322 | 3 MB | 15 MB |
| Chinook database | 11 | 77929 | 1.8 MB | 17 MB |
| Lego database | 8 | 633250 | 13 MB | 42 MB |
| Employees database | 6 | 3919015 | 34 MB | 333 MB |
Note: Installed size is measured using the query:
SELECT pg_size_pretty(pg_database_size('your_database_name')). The reported size for small datasets may appear larger than expected due to inherent Postgres storage overhead.
A table containing data about the periodic table of elements.
Create a periodic_table database:
CREATE DATABASE periodic_table;
Download the source file:
wget https://raw.githubusercontent.com/neondatabase/postgres-sample-dbs/main/periodic_table.sql
Navigate to the directory where you downloaded the source file, and run the following command:
psql -d "postgres://<user>:<password>@<hostname>/periodic_table" -f periodic_table.sqlConnect to the periodic_table database:
psql postgres://<user>:<password>@<hostname>/periodic_table
Look up the the element with the Atomic Number 10:
SELECT * FROM periodic_table WHERE "AtomicNumber" = 10;
Copyright (c) 2017, Chris Andrejewski <christopher.andrejewski@gmail.com>
A dataset with multiple indicators for evaluating the happiness of countries of the world.
Create a world_happiness database:
CREATE DATABASE world_happiness;
Download the source file:
wget https://raw.githubusercontent.com/neondatabase/postgres-sample-dbs/main/happiness_index.sql
Navigate to the directory where you downloaded the source file, and run the following command:
psql -d "postgres://<user>:<password>@<hostname>/world_happiness" -f happiness_index.sqlConnect to the world_happiness database:
psql postgres://<user>:<password>@<hostname>/world_happiness
Find the countries where the happiness score is above average but the GDP per capita is below average:
SELECT country_or_region, score, gdp_per_capita FROM "2019" WHERE score > (SELECT AVG(score) FROM "2019") AND gdp_per_capita < (SELECT AVG(gdp_per_capita) FROM "2019") ORDER BY score DESC;
A dataset containing information on the passengers aboard the RMS Titanic, which sank on its maiden voyage in 1912.
Create a titanic database:
CREATE DATABASE titanic;
Download the source file:
wget https://raw.githubusercontent.com/neondatabase/postgres-sample-dbs/main/titanic.sql
Navigate to the directory where you downloaded the source file, and run the following command:
psql -d "postgres://<user>:<password>@<hostname>/titanic" -f titanic.sqlConnect to the titanic database:
psql postgres://<user>:<password>@<hostname>/titanic
Query passengers with the most expensive fares:
SELECT name, fare FROM passenger ORDER BY fare DESC LIMIT 10;
A dataset containing information about movies and tv shows on Netflix.
Create a netflix database:
CREATE DATABASE netflix;
Download the source file:
wget https://raw.githubusercontent.com/neondatabase/postgres-sample-dbs/main/netflix.sql
Navigate to the directory where you downloaded the source file, and run the following command:
psql -d "postgres://<user>:<password>@<hostname>/netflix" -f netflix.sqlConnect to the netflix database:
psql postgres://<user>:<password>@<hostname>/netflix
Find the directors with the most movies in the database:
SELECT director, COUNT(*) AS "Number of Movies" FROM netflix_shows WHERE type = 'Movie' GROUP BY director ORDER BY "Number of Movies" DESC LIMIT 5;
The official PostgreSQL tutorial sample database (15 tables). A smaller, simpler DVD rental dataset ideal for learning PostgreSQL basics. For a more comprehensive DVD rental database, see Pagila.
Create a dvdrental database:
CREATE DATABASE dvdrental;
Download the source file:
wget https://raw.githubusercontent.com/neondatabase/postgres-sample-dbs/main/dvdrental.sql
Navigate to the directory where you downloaded the source file, and run the following command:
psql -d "postgres://<user>:<password>@<hostname>/dvdrental" -f dvdrental.sqlConnect to the dvdrental database:
psql postgres://<user>:<password>@<hostname>/dvdrental
Find the top 5 customers by total payment amount:
SELECT c.customer_id, c.first_name, c.last_name, SUM(p.amount) AS total_spent FROM customer c JOIN payment p ON c.customer_id = p.customer_id GROUP BY c.customer_id, c.first_name, c.last_name ORDER BY total_spent DESC LIMIT 5;
A more extensive DVD rental database (33 tables). PostgreSQL port of the MySQL Sakila database with additional complexity. Includes tables for films, actors, film categories, stores, customers, payments, and more. For a simpler tutorial version, see DVD rental tutorial database.
Create a pagila database:
CREATE DATABASE pagila;
Download the source file:
wget https://raw.githubusercontent.com/neondatabase/postgres-sample-dbs/main/pagila.sql
Navigate to the directory where you downloaded the source file, and run the following command:
psql -d "postgres://<user>:<password>@<hostname>/pagila" -f pagila.sqlConnect to the pagila database:
psql postgres://<user>:<password>@<hostname>/pagila
Find the top 10 most popular film categories based on rental frequency:
SELECT c.name AS category_name, COUNT(r.rental_id) AS rental_count FROM category c JOIN film_category fc ON c.category_id = fc.category_id JOIN inventory i ON fc.film_id = i.film_id JOIN rental r ON i.inventory_id = r.inventory_id GROUP BY c.name ORDER BY rental_count DESC LIMIT 10;
Copyright (c) Devrim Gündüz <devrim@gunduz.org>A sample database for a digital media store, including tables for artists, albums, media tracks, invoices, customers, and more.
Create a chinook database:
CREATE DATABASE chinook;
Download the source file:
wget https://raw.githubusercontent.com/neondatabase/postgres-sample-dbs/main/chinook.sql
Navigate to the directory where you downloaded the source file, and run the following command:
psql -d "postgres://<user>:<password>@<hostname>/chinook" -f chinook.sqlConnect to the chinook database:
psql postgres://<user>:<password>@<hostname>/chinook
Find out the most sold item by track title:
SELECT T."Name" AS "Track Title", SUM(IL."Quantity") AS "Total Sold" FROM "Track" T JOIN "InvoiceLine" IL ON T."TrackId" = IL."TrackId" GROUP BY T."Name" ORDER BY "Total Sold" DESC LIMIT 1;
Copyright (c) 2008-2017 Luis RochaA dataset containing information about various LEGO sets, their themes, parts, colors, and other associated data.
Create a lego database:
CREATE DATABASE lego;
Download the source file:
wget https://raw.githubusercontent.com/neondatabase/postgres-sample-dbs/main/lego.sql
Navigate to the directory where you downloaded the source file, and run the following command:
psql -d "postgres://<user>:<password>@<hostname>/lego" -f lego.sqlConnect to the lego database:
psql postgres://<user>:<password>@<hostname>/lego
Find the top 5 LEGO themes by the number of sets:
SELECT lt.name AS theme_name, COUNT(ls.set_num) AS number_of_sets FROM lego_themes lt JOIN lego_sets ls ON lt.id = ls.theme_id GROUP BY lt.name ORDER BY number_of_sets DESC LIMIT 5;
A dataset containing details about employees, their departments, salaries, and more.
Create the database:
CREATE DATABASE employees;
Download the source file:
wget https://raw.githubusercontent.com/neondatabase/postgres-sample-dbs/main/employees.sql.gz
Navigate to the directory where you downloaded the source file, and run the following command:
pg_restore -d postgres://<user>:<password>@<hostname>/employees -Fc employees.sql.gz --no-owner --no-privileges
Database objects are created in the employees schema rather than the public schema.
Connect to the employees database:
psql postgres://<user>:<password>@<hostname>/employees
Find the top 5 departments with the highest average salary:
SELECT d.dept_name, AVG(s.amount) AS average_salary FROM employees.salary s JOIN employees.department_employee de ON s.employee_id = de.employee_id JOIN employees.department d ON de.department_id = d.id WHERE s.to_date > CURRENT_DATE AND de.to_date > CURRENT_DATE GROUP BY d.dept_name ORDER BY average_salary DESC LIMIT 5;
This repository is provided under the MIT License. However, please note that each individual database included in this repository is subject to its own license terms.
The MIT License applies to the scripts and other components that we created. We respect the rights of the original creators of the databases, and we only redistribute these databases in compliance with their respective licenses.
For each individual database, we have clearly indicated where the full text of the license can be found. If you choose to use any of these databases, you must comply with the terms specified in their respective licenses.