Class PgConstraintPk

All Implemented Interfaces:
IConstraint, IConstraintPk, ISearchPath, IStatement, ISubElement, PgIndexParamContainer, IHashable

public class PgConstraintPk extends PgConstraint implements IConstraintPk, PgIndexParamContainer
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 Details

    • PgConstraintPk

      public PgConstraintPk(String name, boolean isPrimaryKey)
      Creates a new PostgreSQL PRIMARY KEY or UNIQUE constraint.
      Parameters:
      name - constraint name
      isPrimaryKey - true for PRIMARY KEY, false for UNIQUE
  • Method Details

    • getDefinition

      public String getDefinition()
      Description copied from interface: IConstraint
      Gets the SQL definition of this constraint.
      Specified by:
      getDefinition in interface IConstraint
      Returns:
      the constraint definition
    • setDistinct

      public void setDistinct(boolean isDistinct)
    • addInclude

      public void addInclude(String include)
      Description copied from interface: PgIndexParamContainer
      Adds a column to the INCLUDE clause of the index.
      Specified by:
      addInclude in interface PgIndexParamContainer
      Parameters:
      include - column name to include
    • addParam

      public void addParam(String key, String value)
      Description copied from interface: PgIndexParamContainer
      Adds an index parameter (WITH clause option).
      Specified by:
      addParam in interface PgIndexParamContainer
      Parameters:
      key - parameter name
      value - parameter value
    • setTablespace

      public void setTablespace(String tablespace)
      Description copied from interface: PgIndexParamContainer
      Sets the tablespace for this index.
      Specified by:
      setTablespace in interface PgIndexParamContainer
      Parameters:
      tablespace - tablespace name
    • isPrimaryKey

      public boolean isPrimaryKey()
      Description copied from interface: IConstraint
      Checks if this constraint is a primary key constraint.
      Specified by:
      isPrimaryKey in interface IConstraint
      Returns:
      true if this is a primary key constraint
    • isClustered

      public boolean isClustered()
      Description copied from interface: IConstraintPk
      Checks if this primary key constraint is clustered.
      Specified by:
      isClustered in interface IConstraintPk
      Returns:
      true if the primary key is clustered
    • setClustered

      public void setClustered(boolean isClustered)
    • setWithoutOverlapsColumn

      public void setWithoutOverlapsColumn(String withoutOverlapsColumn)
    • getColumns

      public List<String> getColumns()
      Description copied from interface: IConstraint
      Gets the columns involved in this constraint.
      Specified by:
      getColumns in interface IConstraint
      Overrides:
      getColumns in class PgConstraint
      Returns:
      a collection of column names
    • addColumn

      public void addColumn(String column)
      Adds a column to this constraint.
      Parameters:
      column - column name
    • getErrorCode

      public String getErrorCode()
    • computeHash

      public void computeHash(Hasher hasher)
      Description copied from interface: IHashable
      Computes the hash of the implementing object using the provided hasher. The implementation should call appropriate put methods on the hasher for all fields that should contribute to the hash value.
      Specified by:
      computeHash in interface IHashable
      Overrides:
      computeHash in class PgConstraint
      Parameters:
      hasher - the hasher instance to use for hash computation
    • compare

      public boolean compare(IStatement obj)
      Description copied from class: AbstractStatement
      This method does not account for nested child PgStatements. Shallow version of AbstractStatement.equals(Object)
      Specified by:
      compare in interface IStatement
      Overrides:
      compare in class PgConstraint