Skip to main content

Creating Databases

Overview​

In this lab we will create two databases in PostgreSQL.

Download the files​

  1. Click on these links to download the two .sql files to your virtual machine
  1. Open each file in pgAdmin (or your preferred PostgreSQL client), and review the contents before executing them.

  2. Each script starts with a CREATE DATABASE statement. PostgreSQL doesn't let you create a database and then use it in the same script/connection, so for each file:

    • Run just the first line (CREATE DATABASE pubs; / CREATE DATABASE sports_joins;) while connected to any existing database.
    • Refresh the server's list of databases, then open a new query tool connected to the database you just created.
    • Run the rest of the script in that connection to create the tables and load the data.
  3. Refresh the schemas and look at the databases / tables that have been created.