Package liquibase.database.core
Class MSSQLDatabase
java.lang.Object
liquibase.database.AbstractJdbcDatabase
liquibase.database.core.MSSQLDatabase
- All Implemented Interfaces:
AutoCloseable
,Database
,PrioritizedService
Encapsulates MS-SQL database support.
-
Nested Class Summary
-
Field Summary
Fields inherited from class liquibase.database.AbstractJdbcDatabase
caseSensitive, currentDateTimeFunction, dateFunctions, defaultAutoIncrementBy, defaultAutoIncrementStartWith, defaultCatalogName, defaultSchemaName, quotingStrategy, sequenceCurrentValueFunction, sequenceNextValueFunction, unmodifiableDataTypes, unquotedObjectsAreUppercased
Fields inherited from interface liquibase.database.Database
COMPLETE_SQL_SCOPE_KEY
Fields inherited from interface liquibase.servicelocator.PrioritizedService
COMPARATOR, PRIORITY_DATABASE, PRIORITY_DEFAULT
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static List<SqlVisitor>
addSqlVisitors
(List<SqlVisitor> sqlVisitors) escapeDataTypeName
(String dataTypeName) escapeObjectName
(String objectName, Class<? extends DatabaseObject> objectType) escapeObjectName
(String catalogName, String schemaName, String objectName, Class<? extends DatabaseObject> objectType) escapeTableName
(String catalogName, String schemaName, String tableName) void
executeStatements
(Change change, DatabaseChangeLog changeLog, List<SqlVisitor> sqlVisitors) protected boolean
generateAutoIncrementBy
(BigInteger incrementBy) protected boolean
generateAutoIncrementStartWith
(BigInteger startWith) generateDefaultConstraintName
(String tableName, String columnName) protected String
protected String
protected String
getConcatSql
(String... values) Returns SQL to concat the passed values.protected SqlStatement
Used to obtain the connection schema name through a statement Override this method to change the statement.int
getDataTypeMaxParameters
(String dataTypeName) getDateLiteral
(String isoDate) Return a date literal with the same value as a string formatted using ISO 8601.protected String
getDefaultDriver
(String url) If this database understands the given url, return the default driver class name.int
SQL Standard (Foundation) says: "...ifis not specified, then 6 is implicit." getDefaultScaleForNativeDataType
(String nativeDataType) Returns the default precision for a given native data type, e.g.Determines the capabilities ("Edition") of the SQL Server database.getJdbcSchemaName
(CatalogAndSchema schema) int
protected String
protected String
protected String
Returns an all-lower-case short name of the product.Returns system (undroppable) views.Returns system (undroppable) views.getViewDefinition
(CatalogAndSchema schema, String viewName) boolean
Returns true if the connected MS SQL instance is a Microsoft Cloud ("Azure")-hosted instance of MSSQL.boolean
boolean
Is this AbstractDatabase subclass the correct one to use for the given connection.boolean
isSystemObject
(DatabaseObject example) boolean
Determines if the SQL Server instance assigns Unicode data types (e.g. nvarchar) to strings.void
setDefaultSchemaName
(String schemaName) boolean
supports
(Class<? extends DatabaseObject> object) Whether this database supports the specified object type.boolean
supportsCatalogInObjectName
(Class<? extends DatabaseObject> type) boolean
Does the particular database implementation support the database changelog history feature and associated table?boolean
boolean
Returns whether this database support initially deferrable columns.boolean
boolean
Does the database type support sequence.boolean
unescapeDataTypeName
(String dataTypeName) unescapeDataTypeString
(String dataTypeString) Methods inherited from class liquibase.database.AbstractJdbcDatabase
addReservedWords, canCreateChangeLogTable, close, commit, correctObjectName, correctSchema, correctSchema, createsIndexesForForeignKeys, dataTypeIsNotModifiable, disableForeignKeyChecks, doesTagExist, dropDatabaseObjects, enableForeignKeyChecks, equals, escapeColumnName, escapeColumnName, escapeColumnNameList, escapeConstraintName, escapeIndexName, escapeSequenceName, escapeStringForDatabase, escapeViewName, execute, executeRollbackStatements, executeRollbackStatements, filterRollbackVisitors, generateDatabaseFunctionValue, generatePrimaryKeyName, get, getAutoCommitMode, getAutoIncrementClause, getAutoIncrementClause, getAutoIncrementClosing, getAutoIncrementOpening, getConnection, getConnectionCatalogName, getConnectionSchemaName, getContainingObjects, getCurrentDateTimeFunction, getDatabaseChangeLogLockTableName, getDatabaseChangeLogTableName, getDatabaseMajorVersion, getDatabaseMinorVersion, getDatabaseProductName, getDatabaseProductVersion, getDateFunctions, getDateLiteral, getDateLiteral, getDateTimeLiteral, getDefaultSchema, getDefaultSchemaName, getFetchSize, getJdbcCatalogName, getJdbcCatalogName, getJdbcSchemaName, getLineComment, getLiquibaseCatalogName, getLiquibaseSchemaName, getLiquibaseTablespaceName, getMaxFractionalDigitsForTimestamp, getName, getObjectQuotingStrategy, getOutputDefaultCatalog, getOutputDefaultSchema, getRanChangeSet, getRanChangeSetList, getRanDate, getRawDatabaseChangeLogLockTableName, getRawDatabaseChangeLogTableName, getRunStatus, getSchemaAndCatalogCase, getSchemaFromJdbcInfo, getSystemSchema, getTimeLiteral, hashCode, isAutoCommit, isCatalogOrSchemaType, isCurrentTimeFunction, isDateOnly, isDateTime, isDefaultCatalog, isDefaultSchema, isFunction, isLiquibaseObject, isReservedWord, isSafeToRunUpdate, isSystemView, isTimeOnly, isTimestamp, jdbcCallsCatalogsSchemas, markChangeSetExecStatus, mustQuoteObjectName, parseDate, quoteObject, removeRanStatus, requiresExplicitNullForColumns, requiresPassword, requiresUsername, resetInternalState, rollback, saveRollbackStatement, saveStatements, set, setAutoCommit, setCanCacheLiquibaseTableInfo, setCaseSensitive, setConnection, setCurrentDateTimeFunction, setDatabaseChangeLogLockTableName, setDatabaseChangeLogTableName, setDefaultCatalogName, setLiquibaseCatalogName, setLiquibaseSchemaName, setLiquibaseTablespaceName, setObjectQuotingStrategy, setOutputDefaultCatalog, setOutputDefaultSchema, setPreviousAutoCommit, startsWithNumeric, supportsAutoIncrement, supportsBatchUpdates, supportsCatalogs, supportsDDLInTransaction, supportsForeignKeyDisable, supportsNotNullConstraintNames, supportsPrimaryKeyNames, supportsSchemas, tag, toString, validate
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface liquibase.database.Database
addCompleteSqlToScope, afterUpdate, checkDatabaseConnection, dropDatabaseObjects, failOnDefferable, generateConnectCommandSuccessMessage, getDisplayName, supportsCreateIfNotExists, temporarilySetObjectQuotingStrategy
-
Field Details
-
PRODUCT_NAME
- See Also:
-
MSSQL_DEFAULT_TCP_PORT
protected static final int MSSQL_DEFAULT_TCP_PORT- See Also:
-
systemTablesAndViews
-
-
Constructor Details
-
MSSQLDatabase
public MSSQLDatabase()
-
-
Method Details
-
executeStatements
public void executeStatements(Change change, DatabaseChangeLog changeLog, List<SqlVisitor> sqlVisitors) throws LiquibaseException - Specified by:
executeStatements
in interfaceDatabase
- Overrides:
executeStatements
in classAbstractJdbcDatabase
- Throws:
LiquibaseException
-
addSqlVisitors
-
getDefaultScaleForNativeDataType
Description copied from interface:Database
Returns the default precision for a given native data type, e.g. "datetime2" for Microsoft SQL Server.- Specified by:
getDefaultScaleForNativeDataType
in interfaceDatabase
- Overrides:
getDefaultScaleForNativeDataType
in classAbstractJdbcDatabase
- Parameters:
nativeDataType
- the name of the native data type (case-insensitive).- Returns:
- The default precision of the native data type, or null if the type is unknown to this database.
-
setDefaultSchemaName
- Specified by:
setDefaultSchemaName
in interfaceDatabase
- Overrides:
setDefaultSchemaName
in classAbstractJdbcDatabase
-
getShortName
Description copied from interface:Database
Returns an all-lower-case short name of the product. Used for end-user selecting of database type such as the DBMS precondition. -
getPriority
public int getPriority() -
getDefaultDatabaseProductName
- Specified by:
getDefaultDatabaseProductName
in classAbstractJdbcDatabase
-
getDefaultPort
-
getSystemViews
Description copied from class:AbstractJdbcDatabase
Returns system (undroppable) views.- Overrides:
getSystemViews
in classAbstractJdbcDatabase
-
getSystemTables
Description copied from class:AbstractJdbcDatabase
Returns system (undroppable) views.- Overrides:
getSystemTables
in classAbstractJdbcDatabase
-
supportsInitiallyDeferrableColumns
public boolean supportsInitiallyDeferrableColumns()Description copied from interface:Database
Returns whether this database support initially deferrable columns. -
supports
Description copied from interface:Database
Whether this database supports the specified object type. It is invoking the deprecated methods to ensure that extensions are not broken, but once those are removed it will return only true- Parameters:
object
- the object type to check- Returns:
- true if the database supports the object type, false otherwise
-
supportsSequences
public boolean supportsSequences()Description copied from class:AbstractJdbcDatabase
Does the database type support sequence.- Specified by:
supportsSequences
in interfaceDatabase
- Overrides:
supportsSequences
in classAbstractJdbcDatabase
-
isCorrectDatabaseImplementation
Description copied from interface:Database
Is this AbstractDatabase subclass the correct one to use for the given connection.- Throws:
DatabaseException
-
getDefaultDriver
Description copied from interface:Database
If this database understands the given url, return the default driver class name. Otherwise return null. -
getAutoIncrementClause
- Overrides:
getAutoIncrementClause
in classAbstractJdbcDatabase
-
generateAutoIncrementStartWith
- Overrides:
generateAutoIncrementStartWith
in classAbstractJdbcDatabase
-
generateAutoIncrementBy
- Overrides:
generateAutoIncrementBy
in classAbstractJdbcDatabase
-
getAutoIncrementStartWithClause
- Overrides:
getAutoIncrementStartWithClause
in classAbstractJdbcDatabase
-
getAutoIncrementByClause
- Overrides:
getAutoIncrementByClause
in classAbstractJdbcDatabase
-
getDefaultCatalogName
- Specified by:
getDefaultCatalogName
in interfaceDatabase
- Overrides:
getDefaultCatalogName
in classAbstractJdbcDatabase
-
getConnectionSchemaNameCallStatement
Description copied from class:AbstractJdbcDatabase
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.- Overrides:
getConnectionSchemaNameCallStatement
in classAbstractJdbcDatabase
- See Also:
-
getConcatSql
Description copied from interface:Database
Returns SQL to concat the passed values.- Specified by:
getConcatSql
in interfaceDatabase
- Overrides:
getConcatSql
in classAbstractJdbcDatabase
-
escapeTableName
- Specified by:
escapeTableName
in interfaceDatabase
- Overrides:
escapeTableName
in classAbstractJdbcDatabase
-
supportsTablespaces
public boolean supportsTablespaces() -
isSystemObject
- Specified by:
isSystemObject
in interfaceDatabase
- Overrides:
isSystemObject
in classAbstractJdbcDatabase
-
generateDefaultConstraintName
-
escapeObjectName
- Specified by:
escapeObjectName
in interfaceDatabase
- Overrides:
escapeObjectName
in classAbstractJdbcDatabase
-
getDateLiteral
Description copied from class:AbstractJdbcDatabase
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- Specified by:
getDateLiteral
in interfaceDatabase
- Overrides:
getDateLiteral
in classAbstractJdbcDatabase
-
supportsRestrictForeignKeys
public boolean supportsRestrictForeignKeys()- Specified by:
supportsRestrictForeignKeys
in interfaceDatabase
- Overrides:
supportsRestrictForeignKeys
in classAbstractJdbcDatabase
-
supportsDropTableCascadeConstraints
public boolean supportsDropTableCascadeConstraints()- Specified by:
supportsDropTableCascadeConstraints
in interfaceDatabase
- Overrides:
supportsDropTableCascadeConstraints
in classAbstractJdbcDatabase
-
supportsCatalogInObjectName
- Specified by:
supportsCatalogInObjectName
in interfaceDatabase
- Overrides:
supportsCatalogInObjectName
in classAbstractJdbcDatabase
-
getViewDefinition
- Specified by:
getViewDefinition
in interfaceDatabase
- Overrides:
getViewDefinition
in classAbstractJdbcDatabase
- Throws:
DatabaseException
-
escapeObjectName
public String escapeObjectName(String catalogName, String schemaName, String objectName, Class<? extends DatabaseObject> objectType) - Specified by:
escapeObjectName
in interfaceDatabase
- Overrides:
escapeObjectName
in classAbstractJdbcDatabase
-
getJdbcSchemaName
- Overrides:
getJdbcSchemaName
in classAbstractJdbcDatabase
-
isCaseSensitive
public boolean isCaseSensitive()- Specified by:
isCaseSensitive
in interfaceDatabase
- Overrides:
isCaseSensitive
in classAbstractJdbcDatabase
-
getDataTypeMaxParameters
- Specified by:
getDataTypeMaxParameters
in interfaceDatabase
- Overrides:
getDataTypeMaxParameters
in classAbstractJdbcDatabase
-
escapeDataTypeName
- Specified by:
escapeDataTypeName
in interfaceDatabase
- Overrides:
escapeDataTypeName
in classAbstractJdbcDatabase
-
unescapeDataTypeName
- Specified by:
unescapeDataTypeName
in interfaceDatabase
- Overrides:
unescapeDataTypeName
in classAbstractJdbcDatabase
-
unescapeDataTypeString
- Specified by:
unescapeDataTypeString
in interfaceDatabase
- Overrides:
unescapeDataTypeString
in classAbstractJdbcDatabase
-
sendsStringParametersAsUnicode
public boolean sendsStringParametersAsUnicode()Determines if the SQL Server instance assigns Unicode data types (e.g. nvarchar) to strings.- Returns:
- true if the SQL Server instance uses Unicode types by default, false if not.
-
isAzureDb
public boolean isAzureDb()Returns true if the connected MS SQL instance is a Microsoft Cloud ("Azure")-hosted instance of MSSQL.- Returns:
- true if instance runs in Microsoft Azure, false otherwise
-
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:
- one of the strings above
-
getQuotingStartCharacter
- Overrides:
getQuotingStartCharacter
in classAbstractJdbcDatabase
-
getQuotingEndCharacter
- Overrides:
getQuotingEndCharacter
in classAbstractJdbcDatabase
-
getDefaultFractionalDigitsForTimestamp
public int getDefaultFractionalDigitsForTimestamp()Description copied from class:AbstractJdbcDatabase
SQL Standard (Foundation) says: "...ifis not specified, then 6 is implicit." - Specified by:
getDefaultFractionalDigitsForTimestamp
in interfaceDatabase
- Overrides:
getDefaultFractionalDigitsForTimestamp
in classAbstractJdbcDatabase
- Returns:
- the default precision / number of maximum digits in a timestamp if nothing else is specified.
-
getQuotingEndReplacement
- Overrides:
getQuotingEndReplacement
in classAbstractJdbcDatabase
-
supportsDatabaseChangeLogHistory
public boolean supportsDatabaseChangeLogHistory()Description copied from interface:Database
Does the particular database implementation support the database changelog history feature and associated table?- Returns:
- true if supported, false otherwise
-