/** * 自动移动数据到_del表 */ public void testTable() { String tableName = getPara("tableName"); StringBuilder sb = new StringBuilder("show create table ").append(tableName); Record first = Db.findFirst(sb.toString()); String createTable = first.getStr("Create Table"); int index = createTable.indexOf("("); String delTable = tableName + "_del"; Db.update(new StringBuilder("DROP TABLE IF EXISTS ").append(delTable).append(";").toString()); String ddlDel = new StringBuilder(" create table ").append(delTable) .append("( ").append(createTable.substring(index + 1)).toString(); System.out.println(Db.update(ddlDel)); StringBuilder delSql = new StringBuilder("select * from ").append(tableName).append(" where 1=1 "); if (StrKit.notBlank(getPara("status")) && StrKit.notNull(getPara("statusVal"))) { delSql.append(" and ").append(getPara("status")).append(" = ").append(getPara("statusVal")); } List<Record> recordList = Db.find(delSql.toString()); Db.batchSave(delTable, recordList, recordList.size()); renderJson(true); }