Package liquibase.database
Interface Database
- All Superinterfaces:
- AutoCloseable,- PrioritizedService
- All Known Implementing Classes:
- AbstractDb2Database,- AbstractJdbcDatabase,- CockroachDatabase,- DB2Database,- Db2zDatabase,- DerbyDatabase,- EnterpriseDBDatabase,- FirebirdDatabase,- H2Database,- HsqlDatabase,- InformixDatabase,- Ingres9Database,- MariaDBDatabase,- MockDatabase,- MSSQLDatabase,- MySQLDatabase,- OracleDatabase,- PostgresDatabase,- SnowflakeDatabase,- SQLiteDatabase,- SybaseASADatabase,- SybaseDatabase,- UnsupportedDatabase
Interface that every DBMS supported by this software must implement. Most methods belong into ont of these
 categories:
 Information about the capabilities of the DBMS (e.g. can it work with catalogs? with schemas?) 
 changing and manipulating types defined in the SQL standard into native types and vice-versa 
 creating strings for use in SQL statements, e.g. literals for dates, time, numerals, etc. 
 
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from interface liquibase.servicelocator.PrioritizedServiceCOMPARATOR, PRIORITY_DATABASE, PRIORITY_DEFAULT
- 
Method SummaryModifier and TypeMethodDescriptiondefault voidaddCompleteSqlToScope(String completeSql) voidaddReservedWords(Collection<String> words) default voidAllows the database to perform actions after an update is finished, i.e. after the last change of a changelog was applied.default voidSome databases (such as MongoDB) require you to verify the connection to the database to ensure that the database is accessible.voidclose()voidcommit()correctObjectName(String name, Class<? extends DatabaseObject> objectType) Fix the object name to the format the database expects, handling changes in case, etc.correctSchema(CatalogAndSchema schema) Deprecated.booleanbooleandataTypeIsNotModifiable(String typeName) Types like int4 in postgres cannot have a modifier. e.g. int4(10) Checks whether the type is allowed to have a modifierbooleanbooleandoesTagExist(String tag) Deprecated.UseChangeLogHistoryService.tagExists(String)insteadvoiddropDatabaseObjects(CatalogAndSchema schema) Drops all objects in a specified schema.default voiddropDatabaseObjects(CatalogAndSchema schemaToDrop, SnapshotControl snapshotControl) voidescapeColumnName(String catalogName, String schemaName, String tableName, String columnName) Escapes a single column name in a database-dependent manner so reserved words can be used as a column name (i.e.escapeColumnName(String catalogName, String schemaName, String tableName, String columnName, boolean quoteNamesThatMayBeFunctions) Deprecated.Know if you should quote the name or not, and useescapeColumnName(String, String, String, String)which will quote things that look like functions, or leave it along as you see fit.escapeColumnNameList(String columnNames) Escapes a list of column names in a database-dependent manner so reserved words can be used as a column name (i.e.escapeConstraintName(String constraintName) escapeDataTypeName(String dataTypeName) default StringescapeForLike(String string) escapeIndexName(String catalogName, String schemaName, String indexName) escapeObjectName(String objectName, Class<? extends DatabaseObject> objectType) escapeObjectName(String catalogName, String schemaName, String objectName, Class<? extends DatabaseObject> objectType) escapeSequenceName(String catalogName, String schemaName, String sequenceName) escapeStringForDatabase(String string) escapeTableName(String catalogName, String schemaName, String tableName) escapeViewName(String catalogName, String schemaName, String viewName) voidexecute(SqlStatement[] statements, List<SqlVisitor> sqlVisitors) voidexecuteRollbackStatements(Change change, List<SqlVisitor> sqlVisitors) voidexecuteRollbackStatements(SqlStatement[] statements, List<SqlVisitor> sqlVisitors) voidexecuteStatements(Change change, DatabaseChangeLog changeLog, List<SqlVisitor> sqlVisitors) default booleandefault StringReturns a custom message to be displayed upon successful execution of the connect command.generateDatabaseFunctionValue(DatabaseFunction databaseFunction) Some function names are placeholders that need to be replaced with the specific database value.generatePrimaryKeyName(String tableName) booleanAuto-commit mode to run ingetAutoIncrementClause(BigInteger startWith, BigInteger incrementBy, String generationType, Boolean defaultOnNull) Returns database-specific auto-increment DDL clause.getConcatSql(String... values) Returns SQL to concat the passed values.Returns database-specific function for generating the current date/time.intintReturns the name of the database product according to the underlying database.intgetDataTypeMaxParameters(String dataTypeName) Returns list of database native date functionsgetDateLiteral(String isoDate) getDateLiteral(Date date) getDateLiteral(Date defaultDateValue) getDateTimeLiteral(Timestamp timeStamp) getDefaultDriver(String url) If this database understands the given url, return the default driver class name.intWhen a TIMESTAMP column without the parameter "number of fractional digits" is created, what is the default value?getDefaultScaleForNativeDataType(String nativeDataType) Returns the default precision for a given native data type, e.g.default StringintDetermines the maximum precision (number of fractional digits) for TIMESTAMP columns for the given database.booleanbooleanShould the schema be included in identifiers even if it is the default schema?getRanChangeSet(ChangeSet changeSet) Returns the ChangeSets that have been run against the current database.getRanDate(ChangeSet changeSet) getRunStatus(ChangeSet changeSet) Returns the run status for the given ChangeSetReturns an all-lower-case short name of the product.getTimeLiteral(Time time) getViewDefinition(CatalogAndSchema schema, String name) booleanbooleanbooleanIs this AbstractDatabase subclass the correct one to use for the given connection.booleanisDefaultCatalog(String catalog) If the database supports catalogs, test if a given catalog name equals to the default catalog of the current logged in user.booleanisDefaultSchema(String catalog, String schema) If the database supports schemas, test if a given combination of catalog and schema name equals to the default catalog and schema of the current logged in user.booleanisFunction(String string) booleanisLiquibaseObject(DatabaseObject object) booleanisReservedWord(String string) booleanbooleanisSystemObject(DatabaseObject example) voidmarkChangeSetExecStatus(ChangeSet changeSet, ChangeSet.ExecType execType) After the changeset has been run against the database this method will update the change log table with the information.voidremoveRanStatus(ChangeSet changeSet) booleanDoes the database require explicit NULL for nullable columns?booleanbooleanvoidvoidrollback()voidsaveRollbackStatement(Change change, List<SqlVisitor> sqlVisitors, Writer writer) voidsaveStatements(Change change, List<SqlVisitor> sqlVisitors, Writer writer) voidsetAutoCommit(boolean b) voidsetCanCacheLiquibaseTableInfo(boolean canCacheLiquibaseTableInfo) voidvoidsetCurrentDateTimeFunction(String function) voidsetDatabaseChangeLogLockTableName(String tableName) Set the table name of the change log lock to the given table namevoidsetDatabaseChangeLogTableName(String tableName) Sets the table name of the change log to the given table name.voidsetDefaultCatalogName(String catalogName) voidsetDefaultSchemaName(String schemaName) voidsetLiquibaseCatalogName(String catalogName) voidsetLiquibaseSchemaName(String schemaName) voidsetLiquibaseTablespaceName(String tablespaceName) voidsetObjectQuotingStrategy(ObjectQuotingStrategy quotingStrategy) voidsetOutputDefaultCatalog(boolean outputDefaultCatalog) voidsetOutputDefaultSchema(boolean outputDefaultSchema) Whether the default schema should be included in generated SQLdefault booleansupports(Class<? extends DatabaseObject> object) Whether this database supports the specified object type.booleanbooleanDoes the database support batched DML (INSERT/UPDATE/DELETE/MERGE/...) statements sent in a single call to the database?booleansupportsCatalogInObjectName(Class<? extends DatabaseObject> type) booleanDeprecated.please callsupports(Class)with theCatalogtype insteaddefault booleansupportsCreateIfNotExists(Class<? extends DatabaseObject> type) Does the database support the "if not exits" syntax?default booleanDoes the particular database implementation support the database changelog history feature and associated table?booleanDetermines if the database supports DDL within a transaction or not.booleanbooleanbooleanReturns whether this database support initially deferrable columns.booleanDoes this database treat NOT NULL as an own kind of CONSTRAINT (in addition of simply being a column property)?booleanbooleanbooleanDeprecated.please callsupports(Class)with theSchematype insteadbooleanDeprecated.please callsupports(Class)with theSequencetype insteadbooleanvoidDeprecated.UseChangeLogHistoryService.tag(String)insteaddefault TempObjectQuotingStrategytemporarilySetObjectQuotingStrategy(ObjectQuotingStrategy objectQuotingStrategy) Temporarily set the database's object quoting strategy.unescapeDataTypeName(String dataTypeName) unescapeDataTypeString(String dataTypeString) validate()Methods inherited from interface liquibase.servicelocator.PrioritizedServicegetPriority
- 
Field Details- 
databaseChangeLogTableName
- 
databaseChangeLogLockTableName
- 
COMPLETE_SQL_SCOPE_KEY- See Also:
 
- 
IGNORE_MISSING_REFERENCES_KEY- See Also:
 
 
- 
- 
Method Details- 
isCorrectDatabaseImplementationIs this AbstractDatabase subclass the correct one to use for the given connection.- Throws:
- DatabaseException
 
- 
getDefaultDriverIf this database understands the given url, return the default driver class name. Otherwise return null.
- 
getConnectionDatabaseConnection getConnection()
- 
setConnection
- 
requiresUsernameboolean requiresUsername()
- 
requiresPasswordboolean requiresPassword()
- 
getAutoCommitModeboolean getAutoCommitMode()Auto-commit mode to run in
- 
supportsDDLInTransactionboolean supportsDDLInTransaction()Determines if the database supports DDL within a transaction or not.- Returns:
- True if the database supports DDL within a transaction, otherwise false.
 
- 
getDatabaseProductNameString getDatabaseProductName()Returns the name of the database product according to the underlying database.
- 
getDatabaseProductVersion- Throws:
- DatabaseException
 
- 
getDatabaseMajorVersion- Throws:
- DatabaseException
 
- 
getDatabaseMinorVersion- Throws:
- DatabaseException
 
- 
getShortNameString getShortName()Returns an all-lower-case short name of the product. Used for end-user selecting of database type such as the DBMS precondition.
- 
getDisplayName- Returns:
- a properly formatted name of the product. Used for situations where the database is printed to the console. Example: "Snowflake" (note the capitalization)
 
- 
getDefaultCatalogNameString getDefaultCatalogName()
- 
setDefaultCatalogName- Throws:
- DatabaseException
 
- 
getDefaultSchemaNameString getDefaultSchemaName()
- 
getDefaultScaleForNativeDataTypeReturns the default precision for a given native data type, e.g. "datetime2" for Microsoft SQL Server.- 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- Throws:
- DatabaseException
 
- 
getDefaultPortInteger getDefaultPort()
- 
getFetchSizeInteger getFetchSize()
- 
getLiquibaseCatalogNameString getLiquibaseCatalogName()
- 
setLiquibaseCatalogName
- 
getLiquibaseSchemaNameString getLiquibaseSchemaName()
- 
setLiquibaseSchemaName
- 
supportsInitiallyDeferrableColumnsboolean supportsInitiallyDeferrableColumns()Returns whether this database support initially deferrable columns.
- 
supportsSequencesDeprecated.please callsupports(Class)with theSequencetype insteadWhether this database supports sequences
- 
supportsDropTableCascadeConstraintsboolean supportsDropTableCascadeConstraints()
- 
supportsAutoIncrementboolean supportsAutoIncrement()
- 
getDateLiteral
- 
getCurrentDateTimeFunctionString getCurrentDateTimeFunction()Returns database-specific function for generating the current date/time.
- 
setCurrentDateTimeFunction
- 
getLineCommentString getLineComment()
- 
getAutoIncrementClauseString getAutoIncrementClause(BigInteger startWith, BigInteger incrementBy, String generationType, Boolean defaultOnNull) Returns database-specific auto-increment DDL clause.
- 
getDatabaseChangeLogTableNameString getDatabaseChangeLogTableName()
- 
setDatabaseChangeLogTableNameSets the table name of the change log to the given table name.- Parameters:
- tableName- the name of the change log table to set
 
- 
getDatabaseChangeLogLockTableNameString getDatabaseChangeLogLockTableName()
- 
setDatabaseChangeLogLockTableNameSet the table name of the change log lock to the given table name- Parameters:
- tableName-
 
- 
getLiquibaseTablespaceNameString getLiquibaseTablespaceName()
- 
setLiquibaseTablespaceName
- 
getConcatSqlReturns SQL to concat the passed values.
- 
setCanCacheLiquibaseTableInfovoid setCanCacheLiquibaseTableInfo(boolean canCacheLiquibaseTableInfo) 
- 
dropDatabaseObjectsDrops all objects in a specified schema.- Parameters:
- schema- schema (catalog+)schema to drop
- Throws:
- LiquibaseException- if any problem occurs
 
- 
dropDatabaseObjectsdefault void dropDatabaseObjects(CatalogAndSchema schemaToDrop, SnapshotControl snapshotControl) throws LiquibaseException - Throws:
- LiquibaseException
 
- 
addCompleteSqlToScope
- 
tagDeprecated.UseChangeLogHistoryService.tag(String)insteadTags the database changelog with the given string.- Throws:
- DatabaseException
 
- 
doesTagExistDeprecated.UseChangeLogHistoryService.tagExists(String)instead- Throws:
- DatabaseException
 
- 
isSystemObject
- 
isLiquibaseObject
- 
getViewDefinition- Throws:
- DatabaseException
 
- 
getDateLiteral
- 
getTimeLiteral
- 
getDateTimeLiteral
- 
getDateLiteral
- 
escapeObjectName
- 
escapeTableName
- 
escapeIndexName
- 
escapeObjectName
- 
getMaxFractionalDigitsForTimestampint getMaxFractionalDigitsForTimestamp()Determines the maximum precision (number of fractional digits) for TIMESTAMP columns for the given database. Might not always be able to give an exact answer since, for some DBMS, it depends on the actual software version if fractional digits are supported. A warning should be logged in this case.- Returns:
- the number of allowed fractional digits for TIMESTAMP columns. May return 0.
 
- 
getDefaultFractionalDigitsForTimestampint getDefaultFractionalDigitsForTimestamp()When a TIMESTAMP column without the parameter "number of fractional digits" is created, what is the default value?- Returns:
- The default number of fractional digits for TIMESTAMP columns
 
- 
escapeColumnNameEscapes a single column name in a database-dependent manner so reserved words can be used as a column name (i.e. "return").- Parameters:
- schemaName-
- tableName-
- columnName- column name
- Returns:
- escaped column name
 
- 
escapeColumnName@Deprecated String escapeColumnName(String catalogName, String schemaName, String tableName, String columnName, boolean quoteNamesThatMayBeFunctions) Deprecated.Know if you should quote the name or not, and useescapeColumnName(String, String, String, String)which will quote things that look like functions, or leave it along as you see fit. Don't rely on this function guessing.Similar toescapeColumnName(String, String, String, String)but allows control over whether function-like names should be left unquoted.
- 
escapeColumnNameListEscapes a list of column names in a database-dependent manner so reserved words can be used as a column name (i.e. "return").- Parameters:
- columnNames- list of column names
- Returns:
- escaped column name list
 
- 
supportsTablespacesboolean supportsTablespaces()
- 
supportsCatalogsDeprecated.please callsupports(Class)with theCatalogtype insteadWhether this database supports catalogs
- 
supportsWhether 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
 
- 
getSchemaAndCatalogCaseCatalogAndSchema.CatalogAndSchemaCase getSchemaAndCatalogCase()
- 
supportsSchemasDeprecated.please callsupports(Class)with theSchematype insteadWhether this database supports schemas
- 
supportsCatalogInObjectName
- 
generatePrimaryKeyName
- 
escapeSequenceName
- 
escapeViewName
- 
getRunStatusChangeSet.RunStatus getRunStatus(ChangeSet changeSet) throws DatabaseException, DatabaseHistoryException Returns the run status for the given ChangeSet
- 
getRanChangeSetRanChangeSet getRanChangeSet(ChangeSet changeSet) throws DatabaseException, DatabaseHistoryException 
- 
markChangeSetExecStatusvoid markChangeSetExecStatus(ChangeSet changeSet, ChangeSet.ExecType execType) throws DatabaseException After the changeset has been run against the database this method will update the change log table with the information.- Throws:
- DatabaseException
 
- 
getRanChangeSetListReturns the ChangeSets that have been run against the current database.- Throws:
- DatabaseException
 
- 
getRanDate
- 
removeRanStatus- Throws:
- DatabaseException
 
- 
commit- Throws:
- DatabaseException
 
- 
rollback- Throws:
- DatabaseException
 
- 
escapeStringForDatabase
- 
close- Specified by:
- closein interface- AutoCloseable
- Throws:
- DatabaseException
 
- 
supportsRestrictForeignKeysboolean supportsRestrictForeignKeys()
- 
escapeConstraintName
- 
isAutoCommit- Throws:
- DatabaseException
 
- 
setAutoCommit- Throws:
- DatabaseException
 
- 
isSafeToRunUpdate- Throws:
- DatabaseException
 
- 
executeStatementsvoid executeStatements(Change change, DatabaseChangeLog changeLog, List<SqlVisitor> sqlVisitors) throws LiquibaseException - Throws:
- LiquibaseException
 
- 
execute- Throws:
- LiquibaseException
 
- 
saveStatementsvoid saveStatements(Change change, List<SqlVisitor> sqlVisitors, Writer writer) throws IOException, LiquibaseException - Throws:
- IOException
- LiquibaseException
 
- 
executeRollbackStatementsvoid executeRollbackStatements(Change change, List<SqlVisitor> sqlVisitors) throws LiquibaseException - Throws:
- LiquibaseException
 
- 
executeRollbackStatementsvoid executeRollbackStatements(SqlStatement[] statements, List<SqlVisitor> sqlVisitors) throws LiquibaseException - Throws:
- LiquibaseException
 
- 
saveRollbackStatementvoid saveRollbackStatement(Change change, List<SqlVisitor> sqlVisitors, Writer writer) throws IOException, LiquibaseException - Throws:
- IOException
- LiquibaseException
 
- 
parseDate- Throws:
- DateParseException
 
- 
getDateFunctionsList<DatabaseFunction> getDateFunctions()Returns list of database native date functions
- 
resetInternalStatevoid resetInternalState()
- 
supportsForeignKeyDisableboolean supportsForeignKeyDisable()
- 
disableForeignKeyChecks- Throws:
- DatabaseException
 
- 
enableForeignKeyChecks- Throws:
- DatabaseException
 
- 
isCaseSensitiveboolean isCaseSensitive()
- 
isReservedWord
- 
correctSchemaDeprecated.Returns a new CatalogAndSchema adjusted for this database. Examples of adjustments include: fixes for case issues, replacing null schema or catalog names with the default values removing set schema or catalog names if they are not supported
- 
correctObjectNameFix the object name to the format the database expects, handling changes in case, etc.
- 
isFunction
- 
getDataTypeMaxParameters
- 
getDefaultSchemaCatalogAndSchema getDefaultSchema()
- 
dataTypeIsNotModifiableTypes like int4 in postgres cannot have a modifier. e.g. int4(10) Checks whether the type is allowed to have a modifier- Parameters:
- typeName- type name
- Returns:
- Whether data type can have a modifier
 
- 
generateDatabaseFunctionValueSome function names are placeholders that need to be replaced with the specific database value. e.g. nextSequenceValue(sequenceName) should be replaced with NEXT_VAL('sequenceName') for Postgresql- Parameters:
- databaseFunction- database function to check.
- Returns:
- the string value to use for an update or generate
 
- 
getObjectQuotingStrategyObjectQuotingStrategy getObjectQuotingStrategy()
- 
setObjectQuotingStrategy
- 
createsIndexesForForeignKeysboolean createsIndexesForForeignKeys()
- 
getOutputDefaultSchemaboolean getOutputDefaultSchema()Should the schema be included in identifiers even if it is the default schema?- Returns:
- true (if the schema should be included in every case) or false (omit if default schema)
 
- 
setOutputDefaultSchemavoid setOutputDefaultSchema(boolean outputDefaultSchema) Whether the default schema should be included in generated SQL
- 
isDefaultSchemaIf the database supports schemas, test if a given combination of catalog and schema name equals to the default catalog and schema of the current logged in user.- Parameters:
- catalog- catalog name to be tested
- schema- schema name to be tested
- Returns:
- if the database supports catalogs: true if it is the default schema, false if not. If it does not support schemas, the behaviour of this method is undefined (please call supportsSchemas first!)
 
- 
isDefaultCatalogIf the database supports catalogs, test if a given catalog name equals to the default catalog of the current logged in user.- Parameters:
- catalog- catalog name to be tested
- Returns:
- if the database supports catalogs: true if it is the default catalog, false if not. If it does not support catalogs, the behaviour of this method is undefined (please call supportsCatalog first!)
 
- 
getOutputDefaultCatalogboolean getOutputDefaultCatalog()
- 
setOutputDefaultCatalogvoid setOutputDefaultCatalog(boolean outputDefaultCatalog) 
- 
supportsPrimaryKeyNamesboolean supportsPrimaryKeyNames()
- 
supportsNotNullConstraintNamesboolean supportsNotNullConstraintNames()Does this database treat NOT NULL as an own kind of CONSTRAINT (in addition of simply being a column property)? This will affect the CONSTRAINT clause SQL generators.- Returns:
- true if the database supports naming NOT NULL constraints, false if not.
 
- 
supportsBatchUpdatesDoes the database support batched DML (INSERT/UPDATE/DELETE/MERGE/...) statements sent in a single call to the database?- Returns:
- true if the database has this capability for all DML statements, false in all other cases
- Throws:
- DatabaseException
 
- 
requiresExplicitNullForColumnsboolean requiresExplicitNullForColumns()Does the database require explicit NULL for nullable columns?- Returns:
- true if the database behaves incorrectly if NULL is not explicitly specified, false if it behaves like any good RDBMS should.
 
- 
getSystemSchemaString getSystemSchema()
- 
addReservedWords
- 
escapeDataTypeName
- 
unescapeDataTypeName
- 
unescapeDataTypeString
- 
escapeForLike
- 
validateValidationErrors validate()
- 
failOnDefferabledefault boolean failOnDefferable()
- 
afterUpdateAllows the database to perform actions after an update is finished, i.e. after the last change of a changelog was applied.- Throws:
- LiquibaseException
 
- 
temporarilySetObjectQuotingStrategydefault TempObjectQuotingStrategy temporarilySetObjectQuotingStrategy(ObjectQuotingStrategy objectQuotingStrategy) Temporarily set the database's object quoting strategy. The caller is responsible for callingTempObjectQuotingStrategy.close()on the returned object to reset the object quoting strategy back to its original setting.- Parameters:
- objectQuotingStrategy- the desired quoting strategy
- Returns:
- an object that, when closed, will reset the databases object quoting strategy to the original setting
 
- 
supportsCreateIfNotExistsDoes the database support the "if not exits" syntax?- Parameters:
- type- the DatabaseObject type to be checked.
- Returns:
- true if the "if not exists" syntax is supported, false otherwise.
 
- 
supportsDatabaseChangeLogHistorydefault boolean supportsDatabaseChangeLogHistory()Does the particular database implementation support the database changelog history feature and associated table?- Returns:
- true if supported, false otherwise
 
- 
checkDatabaseConnectionSome databases (such as MongoDB) require you to verify the connection to the database to ensure that the database is accessible. It can be "ping" signal to the database- Throws:
- DatabaseException
 
- 
generateConnectCommandSuccessMessageReturns a custom message to be displayed upon successful execution of the connect command. This method can be overridden by a database implementation to provide a specific message. If not overridden, it returns null by default.- Returns:
- A custom success message for the connect command, or null if not provided.
 
 
- 
CatalogAndSchema.standardize(Database)