it is very easy to drop an existing hsqldb table. however, you need to be very careful while deleting any existing table as any data lost will not be recovered after deleting a table.
syntax
following is a generic sql syntax to drop a hsqldb table.
drop table table_name;
example
let us consider an example to drop a table named employee from the hsqldb server. following is the query to drop a table named employee.
drop table employee;
after execution of the above query, you will receive the following output −
(0) rows effected
hsqldb – jdbc program
following is the jdbc program used to drop the table employee from the hsqldb server.
save the following code into droptable.java file.
import java.sql.connection;
import java.sql.drivermanager;
import java.sql.statement;
public class droptable {
public static void main(string[] args) {
connection con = null;
statement stmt = null;
int result = 0;
try {
class.forname("org.hsqldb.jdbc.jdbcdriver");
con = drivermanager.getconnection("jdbc:hsqldb:hsql://localhost/testdb", "sa", "");
stmt = con.createstatement();
result = stmt.executeupdate("drop table employee");
}catch (exception e) {
e.printstacktrace(system.out);
}
system.out.println("table dropped successfully");
}
}
you can start the database using the following command.
\>cd c:\hsqldb-2.3.4\hsqldb hsqldb>java -classpath lib/hsqldb.jar org.hsqldb.server.server --database.0 file:hsqldb/demodb --dbname.0 testdb
compile and execute the above program using the following command.
\>javac droptable.java \>java droptable
after execution of the above command, you will receive the following output −
table dropped successfully