-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
32 lines (30 loc) · 1.17 KB
/
schema.sql
File metadata and controls
32 lines (30 loc) · 1.17 KB
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
29
30
31
32
-- =============================================================
-- Section 1 — Insert and Query Data
-- =============================================================
-- Creates the sqlf_insert_query schema and a single `person`
-- table that you'll populate and query throughout the exercises.
--
-- Load from your shell:
-- psql -U postgres -d sql_exercise \
-- -f 02-sql-fundamentals/01-insert-and-query-data/schema.sql
--
-- Then load the seed data:
-- psql -U postgres -d sql_exercise \
-- -f 02-sql-fundamentals/01-insert-and-query-data/seed.sql
--
-- Safe to re-run — DROP SCHEMA ... CASCADE at the top wipes
-- everything first.
-- =============================================================
DROP SCHEMA IF EXISTS sqlf_insert_query CASCADE;
CREATE SCHEMA sqlf_insert_query;
SET search_path TO sqlf_insert_query;
CREATE TABLE person (
id INTEGER,
first_name VARCHAR(50) NOT NULL,
last_name VARCHAR(50) NOT NULL,
gender CHAR(1) NOT NULL,
dob DATE NOT NULL,
email VARCHAR(150),
phone_number VARCHAR(15),
country_of_origin VARCHAR(50) NOT NULL
);