Top Description Inners Fields Constructors Methods
liquibase.database.core

public Class MSSQLDatabase

extends AbstractJdbcDatabase
Class Inheritance
Imports
liquibase.CatalogAndSchema, .GlobalConfiguration, .Scope, liquibase.change.AbstractSQLChange, .Change, liquibase.changelog.DatabaseChangeLog, liquibase.database.AbstractJdbcDatabase, .DatabaseConnection, .OfflineConnection, liquibase.database.jvm.JdbcConnection, liquibase.exception.DatabaseException, .LiquibaseException, .UnexpectedLiquibaseException, liquibase.executor.ExecutorService, liquibase.sql.visitor.AppendSqlIfNotPresentVisitor, .SqlVisitor, liquibase.statement.SqlStatement, liquibase.statement.core.GetViewDefinitionStatement, .RawSqlStatement, liquibase.structure.DatabaseObject, liquibase.structure.core.*, liquibase.util.JdbcUtil, .StringUtil, java.math.BigInteger, java.sql.PreparedStatement, .ResultSet, .SQLException, java.util.*, java.util.regex.Pattern

Encapsulates MS-SQL database support.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private static final Pattern
private final HashMap<String, Integer>
protected static final int
public static final String
private Boolean
protected Set<String>
Inherited from liquibase.database.AbstractJdbcDatabase:
caseSensitivecurrentDateTimeFunctiondateFunctionsdefaultAutoIncrementBydefaultAutoIncrementStartWithdefaultCatalogNamedefaultSchemaNamequotingStrategysequenceCurrentValueFunctionsequenceNextValueFunctionunmodifiableDataTypesunquotedObjectsAreUppercased

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private List<SqlVisitor>
private static List<String>
public String
public String
public String
public String
public void
protected boolean
protected boolean
public String
protected String
protected String
protected String
public String
getConcatSql(String... values)

Overrides liquibase.database.AbstractJdbcDatabase.getConcatSql.

Implements liquibase.database.Database.getConcatSql.

Returns SQL to concat the passed values.

protected SqlStatement
getConnectionSchemaNameCallStatement()

Overrides liquibase.database.AbstractJdbcDatabase.getConnectionSchemaNameCallStatement.

Used to obtain the connection schema name through a statement Override this method to change the statement.

public int
public String
getDateLiteral(String isoDate)

Overrides liquibase.database.AbstractJdbcDatabase.getDateLiteral.

Implements liquibase.database.Database.getDateLiteral.

Return a date literal with the same value as a string formatted using ISO 8601.

public String
protected String
public String
getDefaultDriver(String url)

Implements liquibase.database.Database.getDefaultDriver.

If this database understands the given url, return the default driver class name.

public int
getDefaultFractionalDigitsForTimestamp()

Overrides liquibase.database.AbstractJdbcDatabase.getDefaultFractionalDigitsForTimestamp.

Implements liquibase.database.Database.getDefaultFractionalDigitsForTimestamp.

SQL Standard (Foundation) says: "...if <timestamp precision> is not specified, then 6 is implicit."

public Integer
public Integer
getDefaultScaleForNativeDataType(String
the name of the native data type (case-insensitive).
nativeDataType
)

Overrides liquibase.database.AbstractJdbcDatabase.getDefaultScaleForNativeDataType.

Implements liquibase.database.Database.getDefaultScaleForNativeDataType.

Returns the default precision for a given native data type, e.g. "datetime2" for Microsoft SQL Server.

public String

Returns:

one of the strings above
getEngineEdition
()

Determines the capabilities ("Edition") of the SQL Server database.

public String
public int
protected String
protected String
protected String
public String
getShortName()

Implements liquibase.database.Database.getShortName.

Returns an all-lower-case short name of the product.

protected Set<String>
getSystemTables()

Overrides liquibase.database.AbstractJdbcDatabase.getSystemTables.

Returns system (undroppable) views.

public Set<String>
getSystemViews()

Overrides liquibase.database.AbstractJdbcDatabase.getSystemViews.

Returns system (undroppable) views.

public String
public boolean

Returns:

true if instance runs in Microsoft Azure, false otherwise
isAzureDb
()

Returns true if the connected MS SQL instance is a Microsoft Cloud ("Azure")-hosted instance of MSSQL.

public boolean
public boolean
isCorrectDatabaseImplementation(DatabaseConnection conn)

Implements liquibase.database.Database.isCorrectDatabaseImplementation.

Is this AbstractDatabase subclass the correct one to use for the given connection.

public boolean
public boolean

Returns:

true if the SQL Server instance uses Unicode types by default, false if not.
sendsStringParametersAsUnicode
()

Determines if the SQL Server instance assigns Unicode data types (e.g. nvarchar) to strings.

public void
public boolean
public boolean
public boolean
supportsInitiallyDeferrableColumns()

Implements liquibase.database.Database.supportsInitiallyDeferrableColumns.

Returns whether this database support initially deferrable columns.

public boolean
public boolean
public boolean
public String
public String
Inherited from liquibase.database.AbstractJdbcDatabase:
addReservedWordscanCreateChangeLogTableclosecommitcorrectObjectNamecorrectSchemacorrectSchemacreatesIndexesForForeignKeysdataTypeIsNotModifiabledisableForeignKeyChecksdoesTagExistdropDatabaseObjectsenableForeignKeyChecksequalsescapeColumnNameescapeColumnNameescapeColumnNameListescapeConstraintNameescapeIndexNameescapeSequenceNameescapeStringForDatabaseescapeViewNameexecuteexecuteRollbackStatementsexecuteRollbackStatementsfilterRollbackVisitorsgenerateDatabaseFunctionValuegeneratePrimaryKeyNamegetgetAutoCommitModegetAutoIncrementClausegetAutoIncrementClausegetAutoIncrementClosinggetAutoIncrementOpeninggetConnectiongetConnectionCatalogNamegetConnectionSchemaNamegetContainingObjectsgetCurrentDateTimeFunctiongetDatabaseChangeLogLockTableNamegetDatabaseChangeLogTableNamegetDatabaseMajorVersiongetDatabaseMinorVersiongetDatabaseProductNamegetDatabaseProductVersiongetDateFunctionsgetDateLiteralgetDateLiteralgetDateTimeLiteralgetDefaultSchemagetDefaultSchemaNamegetFetchSizegetJdbcCatalogNamegetJdbcCatalogNamegetJdbcSchemaNamegetLineCommentgetLiquibaseCatalogNamegetLiquibaseSchemaNamegetLiquibaseTablespaceNamegetMaxFractionalDigitsForTimestampgetNamegetObjectQuotingStrategygetOutputDefaultCataloggetOutputDefaultSchemagetRanChangeSetgetRanChangeSetListgetRanDategetRawDatabaseChangeLogLockTableNamegetRawDatabaseChangeLogTableNamegetRunStatusgetSchemaAndCatalogCasegetSchemaFromJdbcInfogetSystemSchemagetTimeLiteralhashCodeisAutoCommitisCatalogOrSchemaTypeisCurrentTimeFunctionisDateOnlyisDateTimeisDefaultCatalogisDefaultSchemaisFunctionisLiquibaseObjectisReservedWordisSafeToRunUpdateisSystemViewisTimeOnlyisTimestampjdbcCallsCatalogsSchemasmarkChangeSetExecStatusmustQuoteObjectNameparseDatequoteObjectremoveRanStatusrequiresExplicitNullForColumnsrequiresPasswordrequiresUsernameresetInternalStaterollbacksaveRollbackStatementsaveStatementssetsetAutoCommitsetCanCacheLiquibaseTableInfosetCaseSensitivesetConnectionsetCurrentDateTimeFunctionsetDatabaseChangeLogLockTableNamesetDatabaseChangeLogTableNamesetDefaultCatalogNamesetLiquibaseCatalogNamesetLiquibaseSchemaNamesetLiquibaseTablespaceNamesetObjectQuotingStrategysetOutputDefaultCatalogsetOutputDefaultSchemastartsWithNumericsupportsAutoIncrementsupportsBatchUpdatessupportsCatalogssupportsDDLInTransactionsupportsForeignKeyDisablesupportsNotNullConstraintNamessupportsPrimaryKeyNamessupportsSchemastagtoStringvalidate

Field Detail

CREATE_VIEW_AS_PATTERNback to summary
private static final Pattern CREATE_VIEW_AS_PATTERN

Hides liquibase.database.AbstractJdbcDatabase.CREATE_VIEW_AS_PATTERN.

defaultDataTypeParametersback to summary
private final HashMap<String, Integer> defaultDataTypeParameters
MSSQL_DEFAULT_TCP_PORTback to summary
protected static final int MSSQL_DEFAULT_TCP_PORT
PRODUCT_NAMEback to summary
public static final String PRODUCT_NAME
sendsStringParametersAsUnicodeback to summary
private Boolean sendsStringParametersAsUnicode
systemTablesAndViewsback to summary
protected Set<String> systemTablesAndViews

Constructor Detail

MSSQLDatabaseback to summary
public MSSQLDatabase()
Annotations
@SuppressWarnings:squid:S109

Method Detail

addSqlVisitorsback to summary
private List<SqlVisitor> addSqlVisitors(List<SqlVisitor> sqlVisitors)
createReservedWordsCollectionback to summary
private static List<String> createReservedWordsCollection()
escapeDataTypeNameback to summary
public String escapeDataTypeName(String dataTypeName)

Overrides liquibase.database.AbstractJdbcDatabase.escapeDataTypeName.

Implements liquibase.database.Database.escapeDataTypeName.

Annotations
@Override
escapeObjectNameback to summary
public String escapeObjectName(String objectName, Class<? extends DatabaseObject> objectType)

Overrides liquibase.database.AbstractJdbcDatabase.escapeObjectName.

Implements liquibase.database.Database.escapeObjectName.

Annotations
@Override
escapeObjectNameback to summary
public String escapeObjectName(String catalogName, String schemaName, String objectName, Class<? extends DatabaseObject> objectType)

Overrides liquibase.database.AbstractJdbcDatabase.escapeObjectName.

Implements liquibase.database.Database.escapeObjectName.

Annotations
@Override
escapeTableNameback to summary
public String escapeTableName(String catalogName, String schemaName, String tableName)

Overrides liquibase.database.AbstractJdbcDatabase.escapeTableName.

Implements liquibase.database.Database.escapeTableName.

Annotations
@Override
executeStatementsback to summary
public void executeStatements(Change change, DatabaseChangeLog changeLog, List<SqlVisitor> sqlVisitors) throws LiquibaseException

Overrides liquibase.database.AbstractJdbcDatabase.executeStatements.

Implements liquibase.database.Database.executeStatements.

Annotations
@Override
generateAutoIncrementByback to summary
protected boolean generateAutoIncrementBy(BigInteger incrementBy)

Overrides liquibase.database.AbstractJdbcDatabase.generateAutoIncrementBy.

Annotations
@Override
generateAutoIncrementStartWithback to summary
protected boolean generateAutoIncrementStartWith(BigInteger startWith)

Overrides liquibase.database.AbstractJdbcDatabase.generateAutoIncrementStartWith.

Annotations
@Override
generateDefaultConstraintNameback to summary
public String generateDefaultConstraintName(String tableName, String columnName)
getAutoIncrementByClauseback to summary
protected String getAutoIncrementByClause()

Overrides liquibase.database.AbstractJdbcDatabase.getAutoIncrementByClause.

Annotations
@Override
getAutoIncrementClauseback to summary
protected String getAutoIncrementClause()

Overrides liquibase.database.AbstractJdbcDatabase.getAutoIncrementClause.

Annotations
@Override
getAutoIncrementStartWithClauseback to summary
protected String getAutoIncrementStartWithClause()

Overrides liquibase.database.AbstractJdbcDatabase.getAutoIncrementStartWithClause.

Annotations
@Override
getConcatSqlback to summary
public String getConcatSql(String... values)

Overrides liquibase.database.AbstractJdbcDatabase.getConcatSql.

Implements liquibase.database.Database.getConcatSql.

Doc from liquibase.database.Database.getConcatSql.

Returns SQL to concat the passed values.

Annotations
@Override
getConnectionSchemaNameCallStatementback to summary
protected SqlStatement getConnectionSchemaNameCallStatement()

Overrides liquibase.database.AbstractJdbcDatabase.getConnectionSchemaNameCallStatement.

Doc from liquibase.database.AbstractJdbcDatabase.getConnectionSchemaNameCallStatement.

Used to obtain the connection schema name through a statement Override this method to change the statement. Only override this if getConnectionSchemaName is left unchanged or is using this method.

Annotations
@Override
getDataTypeMaxParametersback to summary
public int getDataTypeMaxParameters(String dataTypeName)

Overrides liquibase.database.AbstractJdbcDatabase.getDataTypeMaxParameters.

Implements liquibase.database.Database.getDataTypeMaxParameters.

Annotations
@Override
getDateLiteralback to summary
public String getDateLiteral(String isoDate)

Overrides liquibase.database.AbstractJdbcDatabase.getDateLiteral.

Implements liquibase.database.Database.getDateLiteral.

Doc from liquibase.database.AbstractJdbcDatabase.getDateLiteral.

Return a date literal with the same value as a string formatted using ISO 8601.

Note

many databases accept date literals in ISO8601 format with the 'T' replaced with a space. Only databases which do not accept these strings should need to override this method.

Implementation restriction: Currently, only the following subsets of ISO8601 are supported: yyyy-MM-dd hh:mm:ss yyyy-MM-ddThh:mm:ss

Annotations
@Override
getDefaultCatalogNameback to summary
public String getDefaultCatalogName()

Overrides liquibase.database.AbstractJdbcDatabase.getDefaultCatalogName.

Implements liquibase.database.Database.getDefaultCatalogName.

Annotations
@Override
getDefaultDatabaseProductNameback to summary
protected String getDefaultDatabaseProductName()

Implements abstract liquibase.database.AbstractJdbcDatabase.getDefaultDatabaseProductName.

Annotations
@Override
getDefaultDriverback to summary
public String getDefaultDriver(String url)

Implements liquibase.database.Database.getDefaultDriver.

Doc from liquibase.database.Database.getDefaultDriver.

If this database understands the given url, return the default driver class name. Otherwise return null.

Annotations
@Override
getDefaultFractionalDigitsForTimestampback to summary
public int getDefaultFractionalDigitsForTimestamp()

Overrides liquibase.database.AbstractJdbcDatabase.getDefaultFractionalDigitsForTimestamp.

Implements liquibase.database.Database.getDefaultFractionalDigitsForTimestamp.

Doc from liquibase.database.AbstractJdbcDatabase.getDefaultFractionalDigitsForTimestamp.

SQL Standard (Foundation) says: "...if is not specified, then 6 is implicit."

Returns:int

the default precision / number of maximum digits in a timestamp if nothing else is specified.

Annotations
@Override
getDefaultPortback to summary
public Integer getDefaultPort()

Implements liquibase.database.Database.getDefaultPort.

Annotations
@Override
getDefaultScaleForNativeDataTypeback to summary
public Integer getDefaultScaleForNativeDataType(String nativeDataType)

Overrides liquibase.database.AbstractJdbcDatabase.getDefaultScaleForNativeDataType.

Implements liquibase.database.Database.getDefaultScaleForNativeDataType.

Doc from liquibase.database.Database.getDefaultScaleForNativeDataType.

Returns the default precision for a given native data type, e.g. "datetime2" for Microsoft SQL Server.

Parameters
nativeDataType:String

the name of the native data type (case-insensitive).

Returns:Integer

The default precision of the native data type, or null if the type is unknown to this database.

Annotations
@Override
getEngineEditionback to summary
public String getEngineEdition()

Determines the capabilities ("Edition") of the SQL Server database. Possible values are currently "Personal", "Standard", "Enterprise" (Developer Edition is also reported as Enterprise), "Express" or "Azure".

Returns:String

one of the strings above

getJdbcSchemaNameback to summary
public String getJdbcSchemaName(CatalogAndSchema schema)

Overrides liquibase.database.AbstractJdbcDatabase.getJdbcSchemaName.

Annotations
@Override
getPriorityback to summary
public int getPriority()

Implements liquibase.servicelocator.PrioritizedService.getPriority.

Annotations
@Override
getQuotingEndCharacterback to summary
protected String getQuotingEndCharacter()

Overrides liquibase.database.AbstractJdbcDatabase.getQuotingEndCharacter.

Annotations
@Override
getQuotingEndReplacementback to summary
protected String getQuotingEndReplacement()

Overrides liquibase.database.AbstractJdbcDatabase.getQuotingEndReplacement.

Annotations
@Override
getQuotingStartCharacterback to summary
protected String getQuotingStartCharacter()

Overrides liquibase.database.AbstractJdbcDatabase.getQuotingStartCharacter.

Annotations
@Override
getShortNameback to summary
public String getShortName()

Implements liquibase.database.Database.getShortName.

Doc from liquibase.database.Database.getShortName.

Returns an all-lower-case short name of the product. Used for end-user selecting of database type such as the DBMS precondition.

Annotations
@Override
getSystemTablesback to summary
protected Set<String> getSystemTables()

Overrides liquibase.database.AbstractJdbcDatabase.getSystemTables.

Doc from liquibase.database.AbstractJdbcDatabase.getSystemTables.

Returns system (undroppable) views.

Annotations
@Override
getSystemViewsback to summary
public Set<String> getSystemViews()

Overrides liquibase.database.AbstractJdbcDatabase.getSystemViews.

Doc from liquibase.database.AbstractJdbcDatabase.getSystemViews.

Returns system (undroppable) views.

Annotations
@Override
getViewDefinitionback to summary
public String getViewDefinition(CatalogAndSchema schema, String viewName) throws DatabaseException

Overrides liquibase.database.AbstractJdbcDatabase.getViewDefinition.

Implements liquibase.database.Database.getViewDefinition.

Annotations
@Override
isAzureDbback to summary
public boolean isAzureDb()

Returns true if the connected MS SQL instance is a Microsoft Cloud ("Azure")-hosted instance of MSSQL.

Returns:boolean

true if instance runs in Microsoft Azure, false otherwise

isCaseSensitiveback to summary
public boolean isCaseSensitive()

Overrides liquibase.database.AbstractJdbcDatabase.isCaseSensitive.

Implements liquibase.database.Database.isCaseSensitive.

Annotations
@Override
isCorrectDatabaseImplementationback to summary
public boolean isCorrectDatabaseImplementation(DatabaseConnection conn) throws DatabaseException

Implements liquibase.database.Database.isCorrectDatabaseImplementation.

Doc from liquibase.database.Database.isCorrectDatabaseImplementation.

Is this AbstractDatabase subclass the correct one to use for the given connection.

Annotations
@Override
isSystemObjectback to summary
public boolean isSystemObject(DatabaseObject example)

Overrides liquibase.database.AbstractJdbcDatabase.isSystemObject.

Implements liquibase.database.Database.isSystemObject.

Annotations
@Override
sendsStringParametersAsUnicodeback to summary
public boolean sendsStringParametersAsUnicode()

Determines if the SQL Server instance assigns Unicode data types (e.g. nvarchar) to strings.

Returns:boolean

true if the SQL Server instance uses Unicode types by default, false if not.

setDefaultSchemaNameback to summary
public void setDefaultSchemaName(String schemaName)

Overrides liquibase.database.AbstractJdbcDatabase.setDefaultSchemaName.

Implements liquibase.database.Database.setDefaultSchemaName.

Annotations
@Override
supportsCatalogInObjectNameback to summary
public boolean supportsCatalogInObjectName(Class<? extends DatabaseObject> type)

Overrides liquibase.database.AbstractJdbcDatabase.supportsCatalogInObjectName.

Implements liquibase.database.Database.supportsCatalogInObjectName.

Annotations
@Override
supportsDropTableCascadeConstraintsback to summary
public boolean supportsDropTableCascadeConstraints()

Overrides liquibase.database.AbstractJdbcDatabase.supportsDropTableCascadeConstraints.

Implements liquibase.database.Database.supportsDropTableCascadeConstraints.

Annotations
@Override
supportsInitiallyDeferrableColumnsback to summary
public boolean supportsInitiallyDeferrableColumns()

Implements liquibase.database.Database.supportsInitiallyDeferrableColumns.

Doc from liquibase.database.Database.supportsInitiallyDeferrableColumns.

Returns whether this database support initially deferrable columns.

Annotations
@Override
supportsRestrictForeignKeysback to summary
public boolean supportsRestrictForeignKeys()

Overrides liquibase.database.AbstractJdbcDatabase.supportsRestrictForeignKeys.

Implements liquibase.database.Database.supportsRestrictForeignKeys.

Annotations
@Override
supportsSequencesback to summary
public boolean supportsSequences()

Overrides liquibase.database.AbstractJdbcDatabase.supportsSequences.

Implements liquibase.database.Database.supportsSequences.

Doc from liquibase.database.AbstractJdbcDatabase.supportsSequences.

Does the database type support sequence.

Annotations
@Override
supportsTablespacesback to summary
public boolean supportsTablespaces()

Implements liquibase.database.Database.supportsTablespaces.

Annotations
@Override
unescapeDataTypeNameback to summary
public String unescapeDataTypeName(String dataTypeName)

Overrides liquibase.database.AbstractJdbcDatabase.unescapeDataTypeName.

Implements liquibase.database.Database.unescapeDataTypeName.

Annotations
@Override
unescapeDataTypeStringback to summary
public String unescapeDataTypeString(String dataTypeString)

Overrides liquibase.database.AbstractJdbcDatabase.unescapeDataTypeString.

Implements liquibase.database.Database.unescapeDataTypeString.

Annotations
@Override
liquibase.database.core back to summary

public final Class MSSQLDatabase.MSSQL_SERVER_VERSIONS

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final int
public static final int
public static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

MSSQL2008back to summary
public static final int MSSQL2008
MSSQL2012back to summary
public static final int MSSQL2012
MSSQL2014back to summary
public static final int MSSQL2014
MSSQL2016back to summary
public static final int MSSQL2016
MSSQL2017back to summary
public static final int MSSQL2017

Constructor Detail

MSSQL_SERVER_VERSIONSback to summary
private MSSQL_SERVER_VERSIONS()