● videoExtraction
Importing the Master Plan

Unlock PostgreSQL Fundamentals
2 hours of SQL video using NASA's Cassini data. See why developers become data pros.
SECTION
Extraction
NEXT UP
Inspecting the Master Plan
COURSE
PostgreSQL Fundamentals
28 lessons
About this lesson
When importing data into Postgres from a CSV, it's imperative that you do not try to alter the data - do that by explicitly transforming the data later on.
That means we need to import everything as text, because that's the core string type in Postgres (as opposed to text etc).
To create our schema and table:
<span class="hljs-keyword">create</span> schema csvs;
<span class="hljs-keyword">create table</span> csvs.master_plan(
start_time_utc text,
duration text,
<span class="hljs-type">date</span> text,
team text,
spass_type text,
target text,
request_name text,
library_definition text,
title text,
description text
);
Copying data from a CSV into our new table:
<span class="hljs-keyword">copy</span> csvs.master_plan
<span class="hljs-keyword">from</span> <span class="hljs-string">'[Absolute path to]/csvs/master_plan.csv'</span>
delimiter <span class="hljs-string">','</span> header csv;
Unlock PostgreSQL Fundamentals
2 hours of SQL video using NASA's Cassini data. See why developers become data pros.