Skip to content

Instantly share code, notes, and snippets.

@PostgreSqlStan
Last active August 6, 2023 15:44
Show Gist options
  • Save PostgreSqlStan/9401f406ec2ac136c504a8b987131301 to your computer and use it in GitHub Desktop.
Save PostgreSqlStan/9401f406ec2ac136c504a8b987131301 to your computer and use it in GitHub Desktop.
Install postgres pagila (DVD rental) database

Install pagila in local postgres db

These directions assume postgres is installed locally with a user—preferably not a superuser—with the same name as your OS username.

From the shell:

curl -OL https://github.com/devrimgunduz/pagila/archive/refs/tags/pagila-v3.1.0.tar.gz
tar -xvf pagila-pagila-v3.1.0.tar
cd pagila-pagila-v3.1.0
psql -U postgres  # connect as postgres 

Then, from psql:

create database pagila;
\c pagila
\i pagila-schema.sql
\i pagila-data.sql
create role pagila_dba;
grant all on database pagila to pagila_dba;
grant all on schema public to pagila_dba;
grant all on all tables in schema public to pagila_dba;
grant all on all sequences in schema public to pagila_dba;
-- change "stan" to your OS user name:
grant pagila_dba to stan;
\q

Now from the shell, connect with dba privileges by simply specifying the database name:

psql pagila  # connect as OS user
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment