Package org.h2.constraint
Class ConstraintUnique
java.lang.Object
org.h2.engine.DbObject
org.h2.schema.SchemaObject
org.h2.constraint.Constraint
org.h2.constraint.ConstraintUnique
- All Implemented Interfaces:
Comparable<Constraint>,HasSQL
A unique constraint. This object always backed by a unique index.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.h2.constraint.Constraint
Constraint.Type -
Field Summary
Fields inherited from class org.h2.constraint.Constraint
tableFields inherited from class org.h2.engine.DbObject
AGGREGATE, comment, COMMENT, CONSTANT, CONSTRAINT, database, DOMAIN, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, SYNONYM, TABLE_OR_VIEW, trace, TRIGGER, USERFields inherited from interface org.h2.util.HasSQL
ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS -
Constructor Summary
ConstructorsConstructorDescriptionConstraintUnique(Schema schema, int id, String name, Table table, boolean primaryKey, IndexColumn[] indexColumns, Index index, boolean indexOwner, NullsDistinct nullsDistinct) -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckExistingData(SessionLocal session) Check the existing data.voidcheckRow(SessionLocal session, Table t, Row oldRow, Row newRow) Check if this row fulfils the constraint.The constraint type nameConstruct the CREATE ...getCreateSQLForCopy(Table forTable, 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 tableGet the SQL statement to create this constraint.getIndex()Get the index of this constraint in the source table, or null if no index is used.getReferencedColumns(Table table) Get all referenced columns.booleanisBefore()Check if this constraint needs to be checked before updating the data.voidrebuild()This method is called after a related table has changed (the table was renamed, or columns have been renamed).voidremoveChildrenAndResources(SessionLocal session) Delete all dependent children objects and resources of this object.voidsetIndexOwner(Index index) This index is now the owner of the specified index.booleanCheck if this constraint needs the specified index.Methods inherited from class org.h2.constraint.Constraint
compareTo, getExpression, getReferencedConstraint, getRefTable, getTable, getType, isEverythingMethods inherited from class org.h2.schema.SchemaObject
getSchema, getSQL, getSQLMethods inherited from class org.h2.engine.DbObject
checkRename, equals, getChildren, getComment, getCreateSQLForMeta, getDatabase, getDropSQL, getId, getModificationId, getName, hashCode, invalidate, isTemporary, isValid, rename, setComment, setModified, setObjectName, setTemporary, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.h2.util.HasSQL
getTraceSQL
-
Constructor Details
-
ConstraintUnique
public ConstraintUnique(Schema schema, int id, String name, Table table, boolean primaryKey, IndexColumn[] indexColumns, Index index, boolean indexOwner, NullsDistinct nullsDistinct) - Parameters:
schema- constraint belongs toid- of the constraintname- of the constrainttable- constraint belongs toprimaryKey- true if primary key constraintindexColumns- used by this constraintindex- the indexindexOwner- true if the index is generated by the system and belongs to this constraintnullsDistinct- NULL handling mode
-
-
Method Details
-
getConstraintType
Description copied from class:ConstraintThe constraint type name- Specified by:
getConstraintTypein classConstraint- Returns:
- the name
-
getCreateSQLForCopy
Description copied from class:DbObjectBuild 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- Overrides:
getCreateSQLForCopyin classDbObject- Parameters:
forTable- the new tablequotedName- the quoted name- Returns:
- the SQL statement
-
getCreateSQLWithoutIndexes
Description copied from class:ConstraintGet the SQL statement to create this constraint.- Specified by:
getCreateSQLWithoutIndexesin classConstraint- Returns:
- the SQL statement
-
getCreateSQL
Description copied from class:DbObjectConstruct the CREATE ... SQL statement for this object.- Specified by:
getCreateSQLin classDbObject- Returns:
- the SQL statement
-
getColumns
-
removeChildrenAndResources
Description copied from class:DbObjectDelete all dependent children objects and resources of this object.- Specified by:
removeChildrenAndResourcesin classDbObject- Parameters:
session- the session
-
checkRow
Description copied from class:ConstraintCheck if this row fulfils the constraint. This method throws an exception if not.- Specified by:
checkRowin classConstraint- Parameters:
session- the sessiont- the tableoldRow- the old rownewRow- the new row
-
usesIndex
Description copied from class:ConstraintCheck if this constraint needs the specified index.- Specified by:
usesIndexin classConstraint- Parameters:
idx- the index- Returns:
- true if the index is used
-
setIndexOwner
Description copied from class:ConstraintThis index is now the owner of the specified index.- Specified by:
setIndexOwnerin classConstraint- Parameters:
index- the index
-
getReferencedColumns
Description copied from class:ConstraintGet all referenced columns.- Specified by:
getReferencedColumnsin classConstraint- Parameters:
table- the table- Returns:
- the set of referenced columns
-
isBefore
public boolean isBefore()Description copied from class:ConstraintCheck if this constraint needs to be checked before updating the data.- Specified by:
isBeforein classConstraint- Returns:
- true if it must be checked before updating
-
checkExistingData
Description copied from class:ConstraintCheck the existing data. This method is called if the constraint is added after data has been inserted into the table.- Specified by:
checkExistingDatain classConstraint- Parameters:
session- the session
-
getIndex
Description copied from class:ConstraintGet the index of this constraint in the source table, or null if no index is used.- Overrides:
getIndexin classConstraint- Returns:
- the index
-
rebuild
public void rebuild()Description copied from class:ConstraintThis method is called after a related table has changed (the table was renamed, or columns have been renamed).- Specified by:
rebuildin classConstraint
-
getNullsDistinct
- Returns:
- are nulls distinct
-