diff --git a/src/java/com/samskivert/jdbc/BaseLiaison.java b/src/java/com/samskivert/jdbc/BaseLiaison.java index b4712f5a..37a42889 100644 --- a/src/java/com/samskivert/jdbc/BaseLiaison.java +++ b/src/java/com/samskivert/jdbc/BaseLiaison.java @@ -267,6 +267,17 @@ public abstract class BaseLiaison implements DatabaseLiaison return true; } + public boolean dropTable (Connection conn, String name) + throws SQLException + { + if (!tableExists(conn, name)) { + return false; + } + executeQuery(conn, "DROP TABLE " + tableSQL(name)); + log.info("Table '" + name + "' dropped."); + return true; + } + /** * Create an SQL string that summarizes a column definition in that format generally * accepted in table creation and column addition statements, e.g. diff --git a/src/java/com/samskivert/jdbc/DatabaseLiaison.java b/src/java/com/samskivert/jdbc/DatabaseLiaison.java index 03ead501..260a4f5f 100644 --- a/src/java/com/samskivert/jdbc/DatabaseLiaison.java +++ b/src/java/com/samskivert/jdbc/DatabaseLiaison.java @@ -190,6 +190,12 @@ public interface DatabaseLiaison */ public boolean tableExists (Connection conn, String name) throws SQLException; + /** + * Drops the given table and returns true if the table exists, else returns false. + * Note: the table name is case sensitive. + */ + public boolean dropTable (Connection conn, String name) throws SQLException; + /** * Returns the proper SQL to identify a table. Some databases require table names to be quoted. */