If you want to batch-process over a number of objects in Exasol, scripts that work with the Data Dictionary might do the trick. Let’s say I want to drop all of my tables that start with the letter P:
SQL_EXA> open schema fred; EXA: open schema fred; Rows affected: 0 SQL_EXA> create or replace script droptables as res=query([[select * from exa_user_tables where table_name like 'P%']]) for i=1, #res do query([[drop table ::t]],{t=res[i].TABLE_NAME}) end / EXA: create or replace script droptables... Rows affected: 0 SQL_EXA> select table_name from exa_user_tables; EXA: select table_name from exa_user_tables; TABLE_NAME -------------------------------------------------- P9_TAB P8_TAB 2 rows in resultset.
Amazingly enough, DROP TABLE is an operation that can be rolled back in Exasol. So to safeguard, I can disable autocommit here.
SQL_EXA> set autocommit off; SQL_EXA> execute script droptables; EXA: execute script droptables; Rows affected: 0 SQL_EXA> select table_name from exa_user_tables; EXA: select table_name from exa_user_tables; TABLE_NAME -------------------------------------------------- 0 rows in resultset. SQL_EXA> rollback; EXA: rollback; Rows affected: 0 SQL_EXA> select table_name from exa_user_tables; EXA: select table_name from exa_user_tables; TABLE_NAME --------------------------------------------------- P9_TAB P8_TAB 2 rows in resultset.