We use http://aws.amazon.com/redshift/ and I create / delete temporary tables in reports. Sometimes we encounter cases when someone created a temporary table and could not delete it.
In other databases, such as PostgreSQL, on which Redshift is based, I could simply:
DROP TEMP TABLE IF EXISTS tblfoo;
But this is a syntax error in Redshift. I can check for temporary tables using http://docs.aws.amazon.com/redshift/latest/dg/r_STV_TBL_PERM.html , but this only works if I am a superuser and I do not work as a superuser, I I could go and learn the exceptions, but with my reporting structure, I would rather go the wrong way.
So, how do I, as a regular user and without generating database errors, conditionally delete a temporary table, if it exists?
source
share