I'm working on JSF application that uses a Firebird 3.0 database containing hundreds of tables. I need to delete all tables time to time.

I have checked this query:

DROP TABLE TABLE_NAME

but only one table can be deleted at a time by using this query and its very time consuming for program, can I have another approach to hammer it away?

1 Answers

2
Konstantin Streletsky On

You can create procedure in which drop tables

create or alter procedure PRC_DROP_TABLES
 as
declare variable TBL varchar(50);

begin
 for select r.rdb$relation_name
     from rdb$relation_fields r
     where
     r.rdb$system_flag=0 and r.rdb$view_context is null
     -- and   r.rdb$relation_name not containing  '$' --uncomment and modify this if you what filter tables by condition 
     group by   r.rdb$relation_name
     into :tbl do
     execute statement  'drop table '||:tbl;
end