All Implemented Interfaces:
IOptionContainer, IRelation, ISearchPath, ISimpleOptionContainer, IStatement, IStatementContainer, ITable, IHashable

public class MsTable extends MsAbstractStatementContainer implements ITable, ISimpleOptionContainer
Represents a Microsoft SQL table with support for memory-optimized tables, temporal tables, filestream data, and other Microsoft SQL specific features.
  • Constructor Details

    • MsTable

      public MsTable(String name)
      Creates a new Microsoft SQL table with the specified name.
      Parameters:
      name - the table name
  • Method Details

    • getCreationSQL

      public void getCreationSQL(SQLScript script)
      Description copied from interface: IStatement
      Generates the SQL statements needed to create this database object. This is an abstract method that must be implemented by subclasses to provide the specific CREATE SQL for each object type.
      Specified by:
      getCreationSQL in interface IStatement
      Parameters:
      script - the SQL script to append creation statements to
    • appendAlterSQL

      public ObjectState appendAlterSQL(IStatement newCondition, SQLScript script)
      Description copied from interface: IStatement
      Fill script with object changes and return change type
      Specified by:
      appendAlterSQL in interface IStatement
      Parameters:
      newCondition - new object state
      script - script to collect changes
      Returns:
      object change type
    • isRecreated

      public boolean isRecreated(ITable newTable, ISettings settings)
      Description copied from interface: ITable
      Compares this table with the newTable to determine if a full table recreation is required. A full recreation (DROP and CREATE) is needed when the tables differ in ways that cannot be altered using ALTER TABLE statements.
      Specified by:
      isRecreated in interface ITable
      Parameters:
      newTable - the new table definition to compare against
      settings - application settings that may affect the comparison logic
      Returns:
      true if the table requires recreation (DROP and CREATE) rather than being alterable, false if the changes can be applied via ALTER TABLE
    • compareTableOptions

      public void compareTableOptions(MsTable newTable, SQLScript script)
      Compares table options between this table and the new table, generating appropriate SQL scripts for change tracking and system versioning differences.
      Parameters:
      newTable - the new table to compare against
      script - the script to append SQL statements to
    • getDropSQL

      public void getDropSQL(SQLScript script, boolean generateExists)
      Description copied from interface: IStatement
      Generates DROP SQL for this statement.
      Specified by:
      getDropSQL in interface IStatement
      Overrides:
      getDropSQL in class AbstractStatement
      Parameters:
      script - the SQL script to append the DROP statement to
      generateExists - whether to include "IF EXISTS" in the DROP statement
    • appendMoveDataSql

      public void appendMoveDataSql(IStatement newCondition, SQLScript script, String tblTmpBareName, List<String> identityCols)
      Description copied from interface: ITable
      Adds commands to the script for move data from the temporary table to the new table, given the identity columns, and a command to delete the temporary table.
      Specified by:
      appendMoveDataSql in interface ITable
    • compareIgnoringColumnOrder

      public boolean compareIgnoringColumnOrder(ITable newTable)
      Specified by:
      compareIgnoringColumnOrder in interface ITable
      Parameters:
      newTable - new state of the table
      Returns:
      true if the tables are identical
    • isClustered

      public boolean isClustered()
      Description copied from class: MsAbstractStatementContainer
      Checks if this container has any clustered indexes or constraints.
      Overrides:
      isClustered in class MsAbstractStatementContainer
    • getPkeys

      public List<MsConstraint> getPkeys()
      Gets the list of primary key constraints for memory-optimized tables.
      Returns:
      unmodifiable list of primary key constraints
    • setFileStream

      public void setFileStream(String fileStream)
    • setTextImage

      public void setTextImage(String textImage)
    • setAnsiNulls

      public void setAnsiNulls(boolean ansiNulls)
    • isTracked

      public boolean isTracked()
      Checks if change tracking is enabled for this table.
      Returns:
      true if change tracking is enabled
    • setTracked

      public void setTracked(Boolean isTracked)
    • getTablespace

      public String getTablespace()
    • setTablespace

      public void setTablespace(String tablespace)
    • setPeriodStartCol

      public void setPeriodStartCol(MsColumn periodStartCol)
    • setPeriodEndCol

      public void setPeriodEndCol(MsColumn periodEndCol)
    • isMemoryOptimized

      public boolean isMemoryOptimized()
      Checks if this table is memory-optimized.
      Returns:
      true if the table is memory-optimized
    • setSysVersioning

      public void setSysVersioning(String sysVersioning)
    • addChild

      public void addChild(IStatement st)
      Description copied from interface: IStatementContainer
      Adds a child statement to this container.
      Specified by:
      addChild in interface IStatementContainer
      Overrides:
      addChild in class MsAbstractStatementContainer
      Parameters:
      st - the child statement to add
    • getChild

      public AbstractStatement getChild(String name, DbObjType type)
      Description copied from interface: IStatementContainer
      Gets a child statement by name and type.
      Specified by:
      getChild in interface IStatementContainer
      Overrides:
      getChild in class MsAbstractStatementContainer
      Parameters:
      name - the name of the child to find
      type - the type of the child to find
      Returns:
      the child statement, or null if not found
    • getChildrenByType

      public Collection<IStatement> getChildrenByType(DbObjType type)
      Description copied from interface: IStatementContainer
      get all children by type
      Specified by:
      getChildrenByType in interface IStatementContainer
      Overrides:
      getChildrenByType in class MsAbstractStatementContainer
      Parameters:
      type - the type of the children
      Returns:
      unmodifiable collection of child statement, or empty list
    • fillChildrenList

      public void fillChildrenList(List<Collection<? extends AbstractStatement>> l)
      Overrides:
      fillChildrenList in class MsAbstractStatementContainer
    • getColumn

      public MsColumn getColumn(String name)
      Specified by:
      getColumn in interface ITable
    • getColumns

      public List<IColumn> getColumns()
      Getter for columns. The list cannot be modified.
      Specified by:
      getColumns in interface ITable
      Returns:
      columns
    • getConstraints

      public Collection<IConstraint> getConstraints()
      Specified by:
      getConstraints in interface ITable
    • containsColumn

      public boolean containsColumn(String name)
      Checks if a column with the specified name exists.
      Parameters:
      name - the column name
      Returns:
      true if column exists, false otherwise
    • addOption

      public void addOption(String key, String value)
      Description copied from interface: IOptionContainer
      Adds an option to this container.
      Specified by:
      addOption in interface IOptionContainer
      Parameters:
      key - the option key
      value - the option value
    • getOptions

      public Map<String,String> getOptions()
      Description copied from interface: IOptionContainer
      Gets all options for this container.
      Specified by:
      getOptions in interface IOptionContainer
      Returns:
      a map of option keys to values
    • getRelationColumns

      public Stream<Pair<String,String>> getRelationColumns()
      Description copied from interface: IRelation
      Gets the columns of this relation as name-type pairs.
      Specified by:
      getRelationColumns in interface IRelation
      Returns:
      a stream of column name and type pairs
    • addColumn

      public void addColumn(MsColumn column)
    • getConstraint

      public MsConstraint getConstraint(String name)
    • 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
      Parameters:
      hasher - the hasher instance to use for hash computation
    • computeChildrenHash

      public void computeChildrenHash(Hasher hasher)
      Overrides:
      computeChildrenHash in class MsAbstractStatementContainer
    • 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 AbstractStatement
    • compareChildren

      public boolean compareChildren(AbstractStatement obj)
      Description copied from class: AbstractStatement
      Deep part of AbstractStatement.equals(Object). Compares all object's child PgStatements for equality.
      Overrides:
      compareChildren in class MsAbstractStatementContainer