Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon Redshift : drop table if exists

Does Redshift support any statement equivalent to the following?

DROP TABLE IF EXISTS tablename
like image 291
Attilah Avatar asked Nov 24 '13 00:11

Attilah


1 Answers

This is supported in the latest version of Redshift:

DROP TABLE [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]

IF EXISTS Clause that indicates that if the specified table doesn’t exist, the command should make no changes and return a message that the table doesn't exist, rather than terminating with an error.

This clause is useful when scripting, so the script doesn’t fail if DROP TABLE runs against a nonexistent table.

Taken from online AWS Redshift docs.

like image 72
mark.monteiro Avatar answered Oct 06 '22 00:10

mark.monteiro