-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb_init.sql
More file actions
28 lines (20 loc) · 872 Bytes
/
db_init.sql
File metadata and controls
28 lines (20 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
-- TO CREATE THIS DATABASE RUN: psql -h localhost -U josephlarrivy -d postgres -f db_init.sql
-- TO CONNECT TO PSQL IN THE TERMINAL AND VIEW THIS DATABASE RUN: psql -h localhost -U josephlarrivy -d gatewayprojectflaskdatabase
-- Connect to the default "postgres" database (or another database that is not the one you want to drop)
\c postgres
-- Drop the existing database
DROP DATABASE IF EXISTS gatewayprojectflaskdatabase;
-- Recreate the database
CREATE DATABASE gatewayprojectflaskdatabase;
\c gatewayprojectflaskdatabase;
DROP TABLE IF EXISTS users CASCADE;
DROP TABLE IF EXISTS sports CASCADE;
CREATE TABLE users (
user_id VARCHAR(255) PRIMARY KEY
);
CREATE TABLE sports (
sport_id SERIAL PRIMARY KEY,
sport_name VARCHAR(100) UNIQUE NOT NULL
);
-- Insert some initial data into the Users table
INSERT INTO sports (sport_name) VALUES ('hockey');