@Override public void dropTables(final Set<TableReference> tableRefs) throws InsufficientConsistencyException { if (tableRefs.isEmpty()) { return; } run((Function<DSLContext, Void>) ctx -> { for (TableReference tableRef : tableRefs) { ctx.dropTableIfExists(tableName(tableRef)).execute(); } ctx.deleteFrom(METADATA_TABLE) .where(TABLE_NAME.in(tableRefs)) .execute(); return null; }); }
@Override public DropTableStep dropTableIfExists(Name table) { return delegate.dropTableIfExists(table); }
@Override public DropTableStep dropTableIfExists( Table<?> table) { return delegate.dropTableIfExists(table); }
@Override public DropTableStep dropTableIfExists(String table) { return delegate.dropTableIfExists(table); }
/** * Create a new DSL <code>DROP TABLE IF EXISTS</code> statement. * <p> * If your database doesn't natively support <code>IF EXISTS</code>, this is * emulated by catching (and ignoring) the relevant {@link SQLException}. * * @see DSLContext#dropTableIfExists(String) */ @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE }) public static DropTableStep dropTableIfExists(String table) { return dsl().dropTableIfExists(table); }
/** * Create a new DSL <code>DROP TABLE IF EXISTS</code> statement. * <p> * If your database doesn't natively support <code>IF EXISTS</code>, this is * emulated by catching (and ignoring) the relevant {@link SQLException}. * * @see DSLContext#dropTableIfExists(Name) */ @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE }) public static DropTableStep dropTableIfExists(Name table) { return dsl().dropTableIfExists(table); }
/** * Create a new DSL <code>DROP TABLE IF EXISTS</code> statement. * <p> * If your database doesn't natively support <code>IF EXISTS</code>, this is * emulated by catching (and ignoring) the relevant {@link SQLException}. * * @see DSLContext#dropTableIfExists(Table) */ @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, SQLITE }) public static DropTableStep dropTableIfExists(Table<?> table) { return dsl().dropTableIfExists(table); }
private static final DDLQuery parseDropTable(ParserContext ctx, boolean temporary) { boolean ifExists = parseKeywordIf(ctx, "IF EXISTS"); Table<?> tableName = parseTableName(ctx); boolean cascade = parseKeywordIf(ctx, "CASCADE"); boolean restrict = !cascade && parseKeywordIf(ctx, "RESTRICT"); DropTableStep s1; DropTableFinalStep s2; s1 = ifExists ? ctx.dsl.dropTableIfExists(tableName) : temporary ? ctx.dsl.dropTemporaryTable(tableName) : ctx.dsl.dropTable(tableName); s2 = cascade ? s1.cascade() : restrict ? s1.restrict() : s1; return s2; }
DSLContext dsl = DSL.using(ds, dialect); dsl.dropTableIfExists(USERS) .execute(); dsl.createTable(USERS) .execute(); dsl.dropTableIfExists(ITEMS) .execute(); dsl.createTable(ITEMS) Table<Record> DATA = DSL.table(name(table.toUpperCase())); dsl.dropTableIfExists(DATA) .execute(); dsl.createTable(DATA)