01: /*
02: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
03: * (http://h2database.com/html/license.html).
04: * Initial Developer: H2 Group
05: */
06: package org.h2.command.ddl;
07:
08: import java.sql.SQLException;
09:
10: import org.h2.constraint.Constraint;
11: import org.h2.engine.Right;
12: import org.h2.engine.Session;
13: import org.h2.schema.Schema;
14:
15: /**
16: * This class represents the statement
17: * ALTER TABLE DROP CONSTRAINT
18: */
19: public class AlterTableDropConstraint extends SchemaCommand {
20:
21: private String constraintName;
22:
23: public AlterTableDropConstraint(Session session, Schema schema) {
24: super (session, schema);
25: }
26:
27: public void setConstraintName(String string) {
28: constraintName = string;
29: }
30:
31: public int update() throws SQLException {
32: session.commit(true);
33: Constraint constraint = getSchema().getConstraint(
34: constraintName);
35: session.getUser().checkRight(constraint.getTable(), Right.ALL);
36: session.getUser().checkRight(constraint.getRefTable(),
37: Right.ALL);
38: session.getDatabase().removeSchemaObject(session, constraint);
39: return 0;
40: }
41:
42: }
|