Class MsTable
java.lang.Object
org.pgcodekeeper.core.database.base.schema.AbstractStatement
org.pgcodekeeper.core.database.ms.schema.MsAbstractStatement
org.pgcodekeeper.core.database.ms.schema.MsAbstractStatementContainer
org.pgcodekeeper.core.database.ms.schema.MsTable
- All Implemented Interfaces:
IOptionContainer,IRelation,ISearchPath,ISimpleOptionContainer,IStatement,IStatementContainer,ITable,IHashable
Represents a Microsoft SQL table with support for memory-optimized tables,
temporal tables, filestream data, and other Microsoft SQL specific features.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChild(IStatement st) Adds a child statement to this container.voidvoidAdds an option to this container.appendAlterSQL(IStatement newCondition, SQLScript script) Fill script with object changes and return change typevoidappendMoveDataSql(IStatement newCondition, SQLScript script, String tblTmpBareName, List<String> identityCols) 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.booleancompare(IStatement obj) This method does not account for nested child PgStatements.booleanDeep part ofAbstractStatement.equals(Object).booleancompareIgnoringColumnOrder(ITable newTable) voidcompareTableOptions(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.voidcomputeChildrenHash(Hasher hasher) voidcomputeHash(Hasher hasher) Computes the hash of the implementing object using the provided hasher.booleancontainsColumn(String name) Checks if a column with the specified name exists.voidfillChildrenList(List<Collection<? extends AbstractStatement>> l) Gets a child statement by name and type.getChildrenByType(DbObjType type) get all children by typeGetter forcolumns.getConstraint(String name) voidgetCreationSQL(SQLScript script) Generates the SQL statements needed to create this database object.voidgetDropSQL(SQLScript script, boolean generateExists) Generates DROP SQL for this statement.Gets all options for this container.getPkeys()Gets the list of primary key constraints for memory-optimized tables.Gets the columns of this relation as name-type pairs.booleanChecks if this container has any clustered indexes or constraints.booleanChecks if this table is memory-optimized.booleanisRecreated(ITable newTable, ISettings settings) Compares this table with thenewTableto determine if a full table recreation is required.booleanChecks if change tracking is enabled for this table.voidsetAnsiNulls(boolean ansiNulls) voidsetFileStream(String fileStream) voidsetPeriodEndCol(MsColumn periodEndCol) voidsetPeriodStartCol(MsColumn periodStartCol) voidsetSysVersioning(String sysVersioning) voidsetTablespace(String tablespace) voidsetTextImage(String textImage) voidsetTracked(Boolean isTracked) Methods inherited from class org.pgcodekeeper.core.database.ms.schema.MsAbstractStatementContainer
getTriggerMethods inherited from class org.pgcodekeeper.core.database.ms.schema.MsAbstractStatement
appendOwnerSQL, formatSql, getQuoter, getRenameCommand, getSeparator, isOwnedMethods inherited from class org.pgcodekeeper.core.database.base.schema.AbstractStatement
addDependency, addPrivilege, appendAlterComments, appendComments, appendPrivileges, canDrop, canDropBeforeCreate, checkComments, clearPrivileges, deepCopy, equals, fillDescendantsList, getAuthor, getBareName, getChildren, getComment, getDependencies, getDescendants, getDropSQL, getLibName, getLocation, getName, getObjectState, getObjectState, getOwner, getParent, getPrivileges, getQualifiedName, getSQL, getTwin, hasChildren, hashCode, isLib, setAuthor, setComment, setLibName, setLocation, setOwner, setParent, shallowCopy, toStringMethods inherited from interface org.pgcodekeeper.core.database.api.schema.ISearchPath
getContainingSchema, getDatabase, getSchemaName, toObjectReferenceMethods inherited from interface org.pgcodekeeper.core.database.api.schema.ISimpleOptionContainer
appendOptions, compareOptionsMethods inherited from interface org.pgcodekeeper.core.database.api.schema.IStatement
addDependency, appendOwnerSQL, canDrop, canDropBeforeCreate, clearPrivileges, deepCopy, formatSql, getAuthor, getBareName, getChildren, getComment, getDependencies, getDescendants, 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.ITable
getStatementType
-
Constructor Details
-
MsTable
Creates a new Microsoft SQL table with the specified name.- Parameters:
name- the table name
-
-
Method Details
-
getCreationSQL
Description copied from interface:IStatementGenerates 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:
getCreationSQLin interfaceIStatement- Parameters:
script- the SQL script to append creation statements to
-
appendAlterSQL
Description copied from interface:IStatementFill script with object changes and return change type- Specified by:
appendAlterSQLin interfaceIStatement- Parameters:
newCondition- new object statescript- script to collect changes- Returns:
- object change type
-
isRecreated
Description copied from interface:ITableCompares this table with thenewTableto 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:
isRecreatedin interfaceITable- Parameters:
newTable- the new table definition to compare againstsettings- application settings that may affect the comparison logic- Returns:
trueif the table requires recreation (DROP and CREATE) rather than being alterable,falseif the changes can be applied via ALTER TABLE
-
compareTableOptions
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 againstscript- the script to append SQL statements to
-
getDropSQL
Description copied from interface:IStatementGenerates DROP SQL for this statement.- Specified by:
getDropSQLin interfaceIStatement- Overrides:
getDropSQLin classAbstractStatement- Parameters:
script- the SQL script to append the DROP statement togenerateExists- 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:ITableAdds 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:
appendMoveDataSqlin interfaceITable
-
compareIgnoringColumnOrder
- Specified by:
compareIgnoringColumnOrderin interfaceITable- Parameters:
newTable- new state of the table- Returns:
- true if the tables are identical
-
isClustered
public boolean isClustered()Description copied from class:MsAbstractStatementContainerChecks if this container has any clustered indexes or constraints.- Overrides:
isClusteredin classMsAbstractStatementContainer
-
getPkeys
Gets the list of primary key constraints for memory-optimized tables.- Returns:
- unmodifiable list of primary key constraints
-
setFileStream
-
setTextImage
-
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
-
getTablespace
-
setTablespace
-
setPeriodStartCol
-
setPeriodEndCol
-
isMemoryOptimized
public boolean isMemoryOptimized()Checks if this table is memory-optimized.- Returns:
- true if the table is memory-optimized
-
setSysVersioning
-
addChild
Description copied from interface:IStatementContainerAdds a child statement to this container.- Specified by:
addChildin interfaceIStatementContainer- Overrides:
addChildin classMsAbstractStatementContainer- Parameters:
st- the child statement to add
-
getChild
Description copied from interface:IStatementContainerGets a child statement by name and type.- Specified by:
getChildin interfaceIStatementContainer- Overrides:
getChildin classMsAbstractStatementContainer- Parameters:
name- the name of the child to findtype- the type of the child to find- Returns:
- the child statement, or null if not found
-
getChildrenByType
Description copied from interface:IStatementContainerget all children by type- Specified by:
getChildrenByTypein interfaceIStatementContainer- Overrides:
getChildrenByTypein classMsAbstractStatementContainer- Parameters:
type- the type of the children- Returns:
- unmodifiable collection of child statement, or empty list
-
fillChildrenList
- Overrides:
fillChildrenListin classMsAbstractStatementContainer
-
getColumn
-
getColumns
Getter forcolumns. The list cannot be modified.- Specified by:
getColumnsin interfaceITable- Returns:
columns
-
getConstraints
- Specified by:
getConstraintsin interfaceITable
-
containsColumn
Checks if a column with the specified name exists.- Parameters:
name- the column name- Returns:
- true if column exists, false otherwise
-
addOption
Description copied from interface:IOptionContainerAdds an option to this container.- Specified by:
addOptionin interfaceIOptionContainer- Parameters:
key- the option keyvalue- the option value
-
getOptions
Description copied from interface:IOptionContainerGets all options for this container.- Specified by:
getOptionsin interfaceIOptionContainer- Returns:
- a map of option keys to values
-
getRelationColumns
Description copied from interface:IRelationGets the columns of this relation as name-type pairs.- Specified by:
getRelationColumnsin interfaceIRelation- Returns:
- a stream of column name and type pairs
-
addColumn
-
getConstraint
-
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- Parameters:
hasher- the hasher instance to use for hash computation
-
computeChildrenHash
- Overrides:
computeChildrenHashin classMsAbstractStatementContainer
-
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 classAbstractStatement
-
compareChildren
Description copied from class:AbstractStatementDeep part ofAbstractStatement.equals(Object). Compares all object's child PgStatements for equality.- Overrides:
compareChildrenin classMsAbstractStatementContainer
-