First of all, you can delete many tables in a single statement:
DROP TABLE mystuff_table_1, mystuff_table_2, mystuff_table_3 CASCADE;
Next, you could put all of those tables into a separate schema. Add that schema to the default search_path
of your user(s), so it's all transparent.
Then all you need is:
DROP SCHEMA foo CASCADE;
If that's not short enough, create a function that executes the command.
A static SQL function:
CREATE OR REPLACE FUNCTION f_delete12() RETURNS void AS
$func$
DROP TABLE mystuff_table_1, mystuff_table_2, mystuff_table_3, ... CASCADE;
$func$ LANGUAGE sql VOLATILE;
Or a dynamic PL/pgSQL function:
CREATE OR REPLACE FUNCTION f_delete12()
RETURNS void AS
$func$
BEGIN
EXECUTE (
SELECT 'DROP TABLE ' || string_agg('mystuff_table_' || g, ', ')
|| ' CASCADE'
FROM generate_series(1,12) g -- numbers 1 to 12
);
END
$func$ LANGUAGE plpgsql VOLATILE;
Call:
SELECT f_delete12();
For an even more dynamic statement:
How do I drop all tables in psql (PostgreSQL interactive terminal) that starts with a common word?