Public Repository

Last pushed: 2 years ago
Short Description
PSQL demo environment for JOIN queries
Full Description

This is a base image built on ubuntu:latest and with PostgreSQL 9.3 installed. There is a database created with two simple tables loaded with data to practice queries.

Run the container: docker run -i -t briantwalter/joindb:demo ./startdemo

That will start the PostgreSQL server, connect to the joindb database and drop you into a psql shell. From there you can run through this discovery and samples listed below.

Show the tables that exist:

joindb=# \d+
                     List of relations
 Schema |  Name   | Type  |  Owner   | Size  | Description
--------+---------+-------+----------+-------+-------------
 public | table_a | table | postgres | 16 kB |
 public | table_b | table | postgres | 16 kB |
(2 rows)

Show the contents in table_a and table_b:

joindb=# select * from table_a;
 value
-------
 1
 2
 3
 4
(4 rows)

joindb=# select * from table_b;
 value
-------
 3
 4
 5
 6
(4 rows)

Select using an INNER JOIN:

joindb=# select * from table_a inner join table_b on table_a.value = table_b.value;
 value | value
-------+-------
 3     | 3
 4     | 4
(2 rows)

Select using a LEFT OUTER JOIN:

joindb=# select * from table_a left outer join table_b on table_a.value =  table_b.value;
 value | value
-------+-------
 1     |
 2     |
 3     | 3
 4     | 4
(4 rows)

Select using a RIGHT OUTER JOIN:

joindb=# select * from table_a right outer join table_b on table_a.value =  table_b.value;
 value | value
-------+-------
 3     | 3
 4     | 4
       | 5
       | 6
(4 rows)
Docker Pull Command
Owner
briantwalter