● videoExtraction
Creating a Proper Import Script

Unlock PostgreSQL Fundamentals
2 hours of SQL video using NASA's Cassini data. See why developers become data pros.
SECTION
Extraction
NEXT UP
Extraction: Summary
COURSE
PostgreSQL Fundamentals
28 lessons
About this lesson
If we try to run our import script twice we're going to get an error because the schema already exists - as does our table. We could check to see if these things exist first, but it's much easier just to hose everything and rerun.
To do that, we need to drop everything first. We can also avoid errors by ensuring the drop only happens if the schema exists first:
<span class="hljs-keyword">drop</span> schema if <span class="hljs-keyword">exists</span> csvs cascade;
That cascade keyword will drop the target object and all dependent objects on it.
Unlock PostgreSQL Fundamentals
2 hours of SQL video using NASA's Cassini data. See why developers become data pros.