Class PgConstraintNotNull

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

public class PgConstraintNotNull extends PgConstraint
PostgreSQL NOT NULL constraint implementation. NOT NULL constraints ensure that a column cannot contain NULL values. Since PostgreSQL 18, NOT NULL constraints can be named and support NO INHERIT option.
  • Field Details

  • Constructor Details

    • PgConstraintNotNull

      public PgConstraintNotNull(String name)
    • PgConstraintNotNull

      public PgConstraintNotNull(String tableName, String columnName)
  • Method Details

    • getDefinition

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

      public void getDefinitionForColumn(StringBuilder sb)
    • getRenameCommand

      public String getRenameCommand(String newName)
      Description copied from interface: IStatement
      Returns sql command to rename the given object.
      Specified by:
      getRenameCommand in interface IStatement
      Overrides:
      getRenameCommand in class PgAbstractStatement
      Parameters:
      newName - the new name for given object
      Returns:
      sql command to rename the given object
    • getErrorCode

      public String getErrorCode()
    • setNoInherit

      public void setNoInherit(boolean noInherit)
    • getTableName

      public String getTableName()
      Description copied from interface: IConstraint
      Gets the name of the table this constraint belongs to.
      Specified by:
      getTableName in interface IConstraint
      Overrides:
      getTableName in class PgConstraint
      Returns:
      the table name
    • isComplexNotNull

      public boolean isComplexNotNull()
      Returns:
      true if the constraint can only be written via ALTER TABLE
    • 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