Drop Table with same table name

Analytics
Enthusiast

Drop Table with same table name

Is there a way to drop duplicate table? when I query this, it gives me 11 rows. When I tried to run it one by one table does not exist.

 

SELECT databasename, TABLENAME, creatorname, createtimestamp, lastaltertimestamp FROM dbc.tables
WHERE databasename = 'DW_STAGE'
AND TABLENAME LIKE ANY ('%t_untd_td01052_fact_pt2_201709%')
AND lastaltertimestamp < TIMESTAMP '2018-01-01 00:00:00';


Accepted Solutions
Enthusiast

Re: Drop Table with same table name

Found the answer. I used DBC.TABLESV and saw other tables and was able to drop them.

1 ACCEPTED SOLUTION
2 REPLIES
Enthusiast

Re: Drop Table with same table name

Can even drop this one by one.

 

Results:

DROP TABLE dw_stage.t_untd_td01052_fact_pt2_201709;
DROP TABLE dw_stage.t_untd_td01052_fact_pt2_201709;
DROP TABLE dw_stage.t_untd_td01052_fact_pt2_201709;
DROP TABLE dw_stage.t_untd_td01052_fact_pt2_201709;

Enthusiast

Re: Drop Table with same table name

Found the answer. I used DBC.TABLESV and saw other tables and was able to drop them.