Class PgConstraintPk
java.lang.Object
org.pgcodekeeper.core.database.base.schema.AbstractStatement
org.pgcodekeeper.core.database.pg.schema.PgAbstractStatement
org.pgcodekeeper.core.database.pg.schema.PgConstraint
org.pgcodekeeper.core.database.pg.schema.PgConstraintPk
- All Implemented Interfaces:
IConstraint,IConstraintPk,ISearchPath,IStatement,ISubElement,PgIndexParamContainer,IHashable
PostgreSQL PRIMARY KEY and UNIQUE constraint implementation.
Primary key constraints uniquely identify each row and cannot contain NULL values.
Unique constraints ensure no duplicate values but can contain NULLs.
-
Constructor Summary
ConstructorsConstructorDescriptionPgConstraintPk(String name, boolean isPrimaryKey) Creates a new PostgreSQL PRIMARY KEY or UNIQUE constraint. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a column to this constraint.voidaddInclude(String include) Adds a column to the INCLUDE clause of the index.voidAdds an index parameter (WITH clause option).booleancompare(IStatement obj) This method does not account for nested child PgStatements.voidcomputeHash(Hasher hasher) Computes the hash of the implementing object using the provided hasher.Gets the columns involved in this constraint.Gets the SQL definition of this constraint.booleanChecks if this primary key constraint is clustered.booleanChecks if this constraint is a primary key constraint.voidsetClustered(boolean isClustered) voidsetDistinct(boolean isDistinct) voidsetTablespace(String tablespace) Sets the tablespace for this index.voidsetWithoutOverlapsColumn(String withoutOverlapsColumn) Methods inherited from class org.pgcodekeeper.core.database.pg.schema.PgConstraint
appendAlterSQL, appendOptions, containsColumn, getCreationSQL, getDropSQL, getTableName, isNotValid, setDeferrable, setInitially, setNotEnforced, setNotValidMethods inherited from class org.pgcodekeeper.core.database.pg.schema.PgAbstractStatement
addPrivilege, appendDefaultPrivileges, appendOwnerSQL, formatSql, getQuoter, getRenameCommand, isOwnedMethods inherited from class org.pgcodekeeper.core.database.base.schema.AbstractStatement
addDependency, appendAlterComments, appendComments, appendPrivileges, canDrop, canDropBeforeCreate, checkComments, clearPrivileges, compareChildren, deepCopy, equals, fillChildrenList, fillDescendantsList, getAuthor, getBareName, getChildren, getComment, getDependencies, getDescendants, getDropSQL, getLibName, getLocation, getName, getObjectState, getObjectState, getOwner, getParent, getPrivileges, getQualifiedName, getSeparator, getSQL, getTwin, hasChildren, hashCode, isLib, setAuthor, setComment, setLibName, setLocation, setOwner, setParent, shallowCopy, toStringMethods inherited from interface org.pgcodekeeper.core.database.api.schema.IConstraint
containsColumn, getStatementType, getTableNameMethods inherited from interface org.pgcodekeeper.core.database.api.schema.ISearchPath
getDatabase, getSchemaNameMethods inherited from interface org.pgcodekeeper.core.database.api.schema.IStatement
addDependency, appendAlterSQL, appendOwnerSQL, canDrop, canDropBeforeCreate, clearPrivileges, deepCopy, formatSql, getAuthor, getBareName, getChildren, getComment, getCreationSQL, getDependencies, getDescendants, getDropSQL, getLibName, getLocation, getName, getOwner, getParent, getPrivileges, getQualifiedName, getQuotedName, getQuoter, getRenameCommand, getSeparator, getSQL, getTwin, getTypeName, hasChildren, isLib, isOwned, quote, setComment, setLibName, setLocation, setOwner, shallowCopyMethods inherited from interface org.pgcodekeeper.core.database.api.schema.ISubElement
getContainingSchema, toObjectReference
-
Constructor Details
-
PgConstraintPk
Creates a new PostgreSQL PRIMARY KEY or UNIQUE constraint.- Parameters:
name- constraint nameisPrimaryKey- true for PRIMARY KEY, false for UNIQUE
-
-
Method Details
-
getDefinition
Description copied from interface:IConstraintGets the SQL definition of this constraint.- Specified by:
getDefinitionin interfaceIConstraint- Returns:
- the constraint definition
-
setDistinct
public void setDistinct(boolean isDistinct) -
addInclude
Description copied from interface:PgIndexParamContainerAdds a column to the INCLUDE clause of the index.- Specified by:
addIncludein interfacePgIndexParamContainer- Parameters:
include- column name to include
-
addParam
Description copied from interface:PgIndexParamContainerAdds an index parameter (WITH clause option).- Specified by:
addParamin interfacePgIndexParamContainer- Parameters:
key- parameter namevalue- parameter value
-
setTablespace
Description copied from interface:PgIndexParamContainerSets the tablespace for this index.- Specified by:
setTablespacein interfacePgIndexParamContainer- Parameters:
tablespace- tablespace name
-
isPrimaryKey
public boolean isPrimaryKey()Description copied from interface:IConstraintChecks if this constraint is a primary key constraint.- Specified by:
isPrimaryKeyin interfaceIConstraint- Returns:
- true if this is a primary key constraint
-
isClustered
public boolean isClustered()Description copied from interface:IConstraintPkChecks if this primary key constraint is clustered.- Specified by:
isClusteredin interfaceIConstraintPk- Returns:
- true if the primary key is clustered
-
setClustered
public void setClustered(boolean isClustered) -
setWithoutOverlapsColumn
-
getColumns
Description copied from interface:IConstraintGets the columns involved in this constraint.- Specified by:
getColumnsin interfaceIConstraint- Overrides:
getColumnsin classPgConstraint- Returns:
- a collection of column names
-
addColumn
Adds a column to this constraint.- Parameters:
column- column name
-
getErrorCode
-
computeHash
Description copied from interface:IHashableComputes the hash of the implementing object using the provided hasher. The implementation should call appropriateputmethods on the hasher for all fields that should contribute to the hash value.- Specified by:
computeHashin interfaceIHashable- Overrides:
computeHashin classPgConstraint- Parameters:
hasher- the hasher instance to use for hash computation
-
compare
Description copied from class:AbstractStatementThis method does not account for nested child PgStatements. Shallow version ofAbstractStatement.equals(Object)- Specified by:
comparein interfaceIStatement- Overrides:
comparein classPgConstraint
-