
Fail-Proof Imports: The Simple Trick to Error-Free Database Scripts
This is a premium course, which you can purchase below.
We don't like errors when running our imports and, unfortunately since we're human, we're going to have a lot of them. Instead of fixing things piecemeal, it's always better to just rerun everything.
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:
drop schema if exists csvs cascade;
That cascade keyword will drop the target object and all dependent objects on it.