How do i delete all the tables in the schema on Apache Derby DB using JDBC?
If you're working from the command prompt rather than through JDBC, this should get you started.
SELECT 'DROP TABLE ' || schemaname ||'.' || tablename || ';'
FROM SYS.SYSTABLES
INNER JOIN SYS.SYSSCHEMAS ON SYS.SYSTABLES.SCHEMAID = SYS.SYSSCHEMAS.SCHEMAID
;
I think most db providers don't allow DROP TABLE * (or similar).
I think the best way would be to SHOW TABLES and then go through each deleting in a loop via a resultset.
HTH.
Download Squirrel SQL from http://squirrel-sql.sourceforge.net/
Connect to the database.
Expand the TABLE node.
Select the tables that you want to drop.
Right click and select -> Scripts -> Drop table scripts
Run the generated queries
You can even select delete records to empty the selected tables.
Do a little method in java in which you execute a
DROP TABLE [tablename]
tablename
is passed by parameter.
And another method in which you loop over a record set formed by the query
SELECT tablename FROM SYSTABLES
calling the first method.
Derby latest documentation