mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-09-24 23:55:57 +08:00
copy and delete Table
This commit is contained in:
@ -111,4 +111,14 @@ public class DB2DBManage extends DefaultDBManage implements DBManage {
|
||||
String sql = "DROP TABLE " + tableName;
|
||||
SQLExecutor.getInstance().execute(connection, sql, resultSet -> null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyTable(Connection connection, String databaseName, String schemaName, String tableName, String newTableName,boolean copyData) throws SQLException {
|
||||
String sql = "CREATE TABLE " + newTableName + " LIKE " + tableName + " INCLUDING INDEXES";
|
||||
SQLExecutor.getInstance().execute(connection, sql, resultSet -> null);
|
||||
if(copyData){
|
||||
sql = "INSERT INTO " + newTableName + " SELECT * FROM " + tableName;
|
||||
SQLExecutor.getInstance().execute(connection, sql, resultSet -> null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user