Search code examples
javasqlderby

Java Derby Database delete all rows from a table


I need to delete all the rows in an Apache Derby database in Java. If I execute statement.executeUpdate("DELETE FROM TABLENAME WHERE CONDITION=") it works, but if I try statement.executeUpdate("DELETE FROM TABLENAME") it does not delete all the rows. I tried TRUNCATE and it does not work either.

Any ideas.


Solution

  • Use dummy condition to delete all the records :

    DELETE FROM TABLENAME WHERE 1=1;