本文整理汇总了Java中org.h2.engine.Database.renameSchemaObject方法的典型用法代码示例。如果您正苦于以下问题:Java Database.renameSchemaObject方法的具体用法?Java Database.renameSchemaObject怎么用?Java Database.renameSchemaObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.h2.engine.Database
的用法示例。
在下文中一共展示了Database.renameSchemaObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkViews
import org.h2.engine.Database; //导入方法依赖的package包/类
/**
* Check that all views and other dependent objects.
*/
private void checkViews(SchemaObject sourceTable, SchemaObject newTable) {
String sourceTableName = sourceTable.getName();
String newTableName = newTable.getName();
Database db = sourceTable.getDatabase();
// save the real table under a temporary name
String temp = db.getTempTableName(sourceTableName, session);
db.renameSchemaObject(session, sourceTable, temp);
try {
// have our new table impersonate the target table
db.renameSchemaObject(session, newTable, sourceTableName);
checkViewsAreValid(sourceTable);
} finally {
// always put the source tables back with their proper names
try {
db.renameSchemaObject(session, newTable, newTableName);
} finally {
db.renameSchemaObject(session, sourceTable, sourceTableName);
}
}
}
示例2: update
import org.h2.engine.Database; //导入方法依赖的package包/类
@Override
public int update() {
session.commit(true);
Database db = session.getDatabase();
session.getUser().checkRight(oldTable, Right.ALL);
Table t = getSchema().findTableOrView(session, newTableName);
if (t != null && hidden && newTableName.equals(oldTable.getName())) {
if (!t.isHidden()) {
t.setHidden(hidden);
oldTable.setHidden(true);
db.updateMeta(session, oldTable);
}
return 0;
}
if (t != null || newTableName.equals(oldTable.getName())) {
throw DbException.get(ErrorCode.TABLE_OR_VIEW_ALREADY_EXISTS_1, newTableName);
}
if (oldTable.isTemporary()) {
throw DbException.getUnsupportedException("temp table");
}
db.renameSchemaObject(session, oldTable, newTableName);
return 0;
}
示例3: update
import org.h2.engine.Database; //导入方法依赖的package包/类
@Override
public int update() {
session.commit(true);
Database db = session.getDatabase();
Schema schema = oldIndex.getSchema();
if (schema.findIndex(session, newIndexName) != null ||
newIndexName.equals(oldIndex.getName())) {
throw DbException.get(ErrorCode.INDEX_ALREADY_EXISTS_1,
newIndexName);
}
session.getUser().checkRight(oldIndex.getTable(), Right.ALL);
db.renameSchemaObject(session, oldIndex, newIndexName);
return 0;
}