IMPORT FOREIGN SCHEMA IF NOT EXISTS

Viewed 818

Currently IMPORT FOREIGN SCHEMA does not seem to support IF NOT EXISTS so how to solve this case? If I have a script that runs on every reboot for example I would get

ERROR: relation "xxx" already exists

Is there a way to overcome this?

1 Answers

Use the EXCEPT clause to exclude those tables that are already there:

IMPORT FOREIGN SCHEMA xy EXCEPT (xxx, yyy, zzz) FROM ...

Alternatively, delete all foreign tables first. Creating them again shouldn't take too long.

Related