?? dropview.java
字號:
/*
* Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package org.h2.command.ddl;
import java.sql.SQLException;
import org.h2.constant.ErrorCode;
import org.h2.engine.Right;
import org.h2.engine.Session;
import org.h2.message.Message;
import org.h2.schema.Schema;
import org.h2.table.Table;
/**
* This class represents the statement
* DROP VIEW
*/
public class DropView extends SchemaCommand {
private String viewName;
private boolean ifExists;
public DropView(Session session, Schema schema) {
super(session, schema);
}
public void setIfExists(boolean b) {
ifExists = b;
}
public void setViewName(String viewName) {
this.viewName = viewName;
}
public int update() throws SQLException {
// TODO rights: what rights are required to drop a view?
session.commit(true);
Table view = getSchema().findTableOrView(session, viewName);
if (view == null) {
if (!ifExists) {
throw Message.getSQLException(ErrorCode.VIEW_NOT_FOUND_1, viewName);
}
} else {
if (!view.getTableType().equals(Table.VIEW)) {
throw Message.getSQLException(ErrorCode.VIEW_NOT_FOUND_1, viewName);
}
session.getUser().checkRight(view, Right.ALL);
view.lock(session, true, true);
session.getDatabase().removeSchemaObject(session, view);
}
return 0;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -