## org.h2.constraint
Class ConstraintCheck

    java.lang.Object
      org.h2.engine.DbObjectBase
          org.h2.schema.SchemaObjectBase
              org.h2.constraint.Constraint
                  org.h2.constraint.ConstraintCheck

All Implemented Interfaces:
  java.lang.Comparable<Constraint>, DbObject, SchemaObject

    public class ConstraintCheck

extends Constraint

A check constraint.

Field Summary

Fields inherited from class org.h2.constraint.Constraint
`CHECK, PRIMARY_KEY, REFERENTIAL, table, UNIQUE`

Fields inherited from class org.h2.engine.DbObjectBase
`comment, database, trace`

Fields inherited from interface org.h2.engine.DbObject
`AGGREGATE, COMMENT, CONSTANT, CONSTRAINT, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, TABLE_OR_VIEW, TRIGGER, USER, USER_DATATYPE`

Constructor Summary
`ConstraintCheck(Schema schema, int id, java.lang.String name, Table table)`

Method Summary
`void` `checkExistingData(Session session)` Check the existing data.
`void` `checkRow(Session session, Table t, Row oldRow, Row newRow)` Check if this row fulfils the constraint.
`java.lang.String` `getConstraintType()` The constraint type name
`java.lang.String` `getCreateSQL()` Build a SQL statement to re-create this object.
`java.lang.String` `getCreateSQLForCopy(Table forTable, java.lang.String quotedName)` Build a SQL statement to re-create the object, or to create a copy of the object with a different name or referencing a different table
`java.lang.String` `getCreateSQLWithoutIndexes()` Get the SQL statement to create this constraint.
`Expression` `getExpression()`
`java.util.HashSet<Column>` `getReferencedColumns(Table table)` Get all referenced columns.
`Index` `getUniqueIndex()` Get the unique index used to enforce this constraint, or null if no index is used.
`boolean` `isBefore()` Check if this constraint needs to be checked before updating the data.
`void` `rebuild()` This method is called after a related table has changed (the table was renamed, or columns have been renamed).
`void` `removeChildrenAndResources(Session session)` Remove all dependent objects and free all resources (files, blocks in files) of this object.
`void` `setExpression(Expression expr)`
`void` `setIndexOwner(Index index)` This index is now the owner of the specified index.
`void` `setTableFilter(TableFilter filter)`
`boolean` `usesIndex(Index index)` Check if this constraint needs the specified index.

Methods inherited from class org.h2.constraint.Constraint
`checkRename, compareTo, getDropSQL, getRefTable, getTable, getType, isHidden`

Methods inherited from class org.h2.schema.SchemaObjectBase
`getSchema, getSQL, initSchemaObjectBase`

Methods inherited from class org.h2.engine.DbObjectBase
`getChildren, getComment, getDatabase, getId, getModificationId, getName, initDbObjectBase, invalidate, isTemporary, rename, setComment, setModified, setObjectName, setTemporary, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface org.h2.engine.DbObject
`getChildren, getComment, getDatabase, getId, getModificationId, getName, isTemporary, rename, setComment, setModified, setTemporary`

Constructor Detail

### ConstraintCheck

    public ConstraintCheck(Schema schema,
                           int id,
                           java.lang.String name,
                           Table table)

Method Detail

### getConstraintType

    public java.lang.String getConstraintType()

  Description copied from class: `Constraint`
  The constraint type name

  Specified by:
    `getConstraintType` in class `Constraint`
  Returns:
    the name

### setTableFilter

    public void setTableFilter(TableFilter filter)

### setExpression

    public void setExpression(Expression expr)

### getCreateSQLForCopy

    public java.lang.String getCreateSQLForCopy(Table forTable,
                                                java.lang.String quotedName)

  Description copied from class: `DbObjectBase`
  Build a SQL statement to re-create the object, or to create a copy of the object with a different name or referencing a different table

  Specified by:
    `getCreateSQLForCopy` in interface `DbObject`
  Specified by:
    `getCreateSQLForCopy` in class `DbObjectBase`
  Parameters:
    `forTable` - the new table name
    `quotedName` - the new quoted name
  Returns:
    the SQL statement

### getCreateSQLWithoutIndexes

    public java.lang.String getCreateSQLWithoutIndexes()

  Description copied from class: `Constraint`
  Get the SQL statement to create this constraint.

  Specified by:
    `getCreateSQLWithoutIndexes` in class `Constraint`
  Returns:
    the SQL statement

### getCreateSQL

    public java.lang.String getCreateSQL()

  Description copied from class: `DbObjectBase`
  Build a SQL statement to re-create this object.

  Specified by:
    `getCreateSQL` in interface `DbObject`
  Specified by:
    `getCreateSQL` in class `DbObjectBase`
  Returns:
    the SQL statement

### removeChildrenAndResources

    public void removeChildrenAndResources(Session session)

  Description copied from class: `DbObjectBase`
  Remove all dependent objects and free all resources (files, blocks in files) of this object.

  Specified by:
    `removeChildrenAndResources` in interface `DbObject`
  Specified by:
    `removeChildrenAndResources` in class `DbObjectBase`
  Parameters:
    `session` - the session

### checkRow

    public void checkRow(Session session,
                         Table t,
                         Row oldRow,
                         Row newRow)

  Description copied from class: `Constraint`
  Check if this row fulfils the constraint. This method throws an exception if not.

  Specified by:
    `checkRow` in class `Constraint`
  Parameters:
    `session` - the session
    `t` - the table
    `oldRow` - the old row
    `newRow` - the new row

### usesIndex

    public boolean usesIndex(Index index)

  Description copied from class: `Constraint`
  Check if this constraint needs the specified index.

  Specified by:
    `usesIndex` in class `Constraint`
  Parameters:
    `index` - the index
  Returns:
    true if the index is used

### setIndexOwner

    public void setIndexOwner(Index index)

  Description copied from class: `Constraint`
  This index is now the owner of the specified index.

  Specified by:
    `setIndexOwner` in class `Constraint`
  Parameters:
    `index` - the index

### getReferencedColumns

    public java.util.HashSet<Column> getReferencedColumns(Table table)

  Description copied from class: `Constraint`
  Get all referenced columns.

  Specified by:
    `getReferencedColumns` in class `Constraint`
  Parameters:
    `table` - the table
  Returns:
    the set of referenced columns

### getExpression

    public Expression getExpression()

### isBefore

    public boolean isBefore()

  Description copied from class: `Constraint`
  Check if this constraint needs to be checked before updating the data.

  Specified by:
    `isBefore` in class `Constraint`
  Returns:
    true if it must be checked before updating

### checkExistingData

    public void checkExistingData(Session session)

  Description copied from class: `Constraint`
  Check the existing data. This method is called if the constraint is added after data has been inserted into the table.

  Specified by:
    `checkExistingData` in class `Constraint`
  Parameters:
    `session` - the session

### getUniqueIndex

    public Index getUniqueIndex()

  Description copied from class: `Constraint`
  Get the unique index used to enforce this constraint, or null if no index is used.

  Specified by:
    `getUniqueIndex` in class `Constraint`
  Returns:
    the index

### rebuild

    public void rebuild()

  Description copied from class: `Constraint`
  This method is called after a related table has changed (the table was renamed, or columns have been renamed).

  Specified by:
    `rebuild` in class `Constraint`