Class AlterTableAddConstraint


public class AlterTableAddConstraint extends AlterTable
This class represents the statement ALTER TABLE ADD CONSTRAINT
  • Field Details

    • type

      private final int type
    • constraintName

      private String constraintName
    • indexColumns

      private IndexColumn[] indexColumns
    • deleteAction

      private ConstraintActionType deleteAction
    • updateAction

      private ConstraintActionType updateAction
    • refSchema

      private Schema refSchema
    • refTableName

      private String refTableName
    • refIndexColumns

      private IndexColumn[] refIndexColumns
    • checkExpression

      private Expression checkExpression
    • index

      private Index index
    • refIndex

      private Index refIndex
    • comment

      private String comment
    • checkExisting

      private boolean checkExisting
    • primaryKeyHash

      private boolean primaryKeyHash
    • ifNotExists

      private final boolean ifNotExists
    • createdIndexes

      private final ArrayList<Index> createdIndexes
    • createdUniqueConstraint

      private ConstraintUnique createdUniqueConstraint
  • Constructor Details

    • AlterTableAddConstraint

      public AlterTableAddConstraint(SessionLocal session, Schema schema, int type, boolean ifNotExists)
  • Method Details

    • generateConstraintName

      private String generateConstraintName(Table table)
    • update

      public long update(Table table)
      Specified by:
      update in class AlterTable
    • tryUpdate

      private int tryUpdate(Table table)
      Try to execute the statement.
      Returns:
      the update count
    • createUniqueConstraint

      private ConstraintUnique createUniqueConstraint(Table table, Index index, IndexColumn[] indexColumns, boolean forForeignKey)
    • addConstraintToTable

      private void addConstraintToTable(Database db, Table table, Constraint constraint)
    • createIndex

      private Index createIndex(Table t, IndexColumn[] cols, boolean unique)
    • setDeleteAction

      public void setDeleteAction(ConstraintActionType action)
    • setUpdateAction

      public void setUpdateAction(ConstraintActionType action)
    • getUniqueConstraint

      private static ConstraintUnique getUniqueConstraint(Table t, IndexColumn[] cols)
    • getIndex

      private static Index getIndex(Table t, IndexColumn[] cols, boolean unique)
    • canUseIndex

      private static boolean canUseIndex(Index index, Table table, IndexColumn[] cols, boolean unique)
    • setConstraintName

      public void setConstraintName(String constraintName)
    • getConstraintName

      public String getConstraintName()
    • getType

      public int getType()
      Description copied from class: Prepared
      Get the command type as defined in CommandInterface
      Specified by:
      getType in class Prepared
      Returns:
      the statement type
    • setCheckExpression

      public void setCheckExpression(Expression expression)
    • setIndexColumns

      public void setIndexColumns(IndexColumn[] indexColumns)
    • getIndexColumns

      public IndexColumn[] getIndexColumns()
    • setRefTableName

      public void setRefTableName(Schema refSchema, String ref)
      Set the referenced table.
      Parameters:
      refSchema - the schema
      ref - the table name
    • setRefIndexColumns

      public void setRefIndexColumns(IndexColumn[] indexColumns)
    • setIndex

      public void setIndex(Index index)
    • setRefIndex

      public void setRefIndex(Index refIndex)
    • setComment

      public void setComment(String comment)
    • setCheckExisting

      public void setCheckExisting(boolean b)
    • setPrimaryKeyHash

      public void setPrimaryKeyHash(boolean b)