1 5 package org.h2.command.ddl; 6 7 import java.sql.SQLException ; 8 9 import org.h2.constraint.Constraint; 10 import org.h2.engine.Right; 11 import org.h2.engine.Session; 12 import org.h2.schema.Schema; 13 14 17 public class AlterTableDropConstraint extends SchemaCommand { 18 19 private String constraintName; 20 21 public AlterTableDropConstraint(Session session, Schema schema) { 22 super(session, schema); 23 } 24 25 public void setConstraintName(String string) { 26 constraintName = string; 27 } 28 29 public int update() throws SQLException { 30 session.commit(); 31 Constraint constraint = getSchema().getConstraint(constraintName); 32 session.getUser().checkRight(constraint.getTable(), Right.ALL); 33 session.getUser().checkRight(constraint.getRefTable(), Right.ALL); 34 session.getDatabase().removeSchemaObject(session, constraint); 35 return 0; 36 } 37 38 } 39 | Popular Tags |