liquibase.database
Interface Database
- All Superinterfaces:
- PrioritizedService
- All Known Implementing Classes:
- AbstractJdbcDatabase, DB2Database, DerbyDatabase, FirebirdDatabase, H2Database, HsqlDatabase, InformixDatabase, MariaDBDatabase, MockDatabase, MSSQLDatabase, MySQLDatabase, OracleDatabase, PostgresDatabase, SQLiteDatabase, SybaseASADatabase, SybaseDatabase, UnsupportedDatabase
public interface Database
- extends PrioritizedService
Method Summary |
void |
addReservedWords(Collection<String> words)
|
void |
close()
|
void |
commit()
|
String |
correctObjectName(String name,
Class<? extends DatabaseObject> objectType)
Fix the object name to the format the database expects, handling changes in case, etc. |
CatalogAndSchema |
correctSchema(CatalogAndSchema schema)
Deprecated. use CatalogAndSchema.standardize(Database) |
boolean |
createsIndexesForForeignKeys()
|
boolean |
dataTypeIsNotModifiable(String typeName)
Types like int4 in postgres cannot have a modifier. |
boolean |
disableForeignKeyChecks()
|
boolean |
doesTagExist(String tag)
|
void |
dropDatabaseObjects(CatalogAndSchema schema)
|
void |
enableForeignKeyChecks()
|
String |
escapeColumnName(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. |
String |
escapeColumnName(String catalogName,
String schemaName,
String tableName,
String columnName,
boolean quoteNamesThatMayBeFunctions)
|
String |
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. |
String |
escapeConstraintName(String constraintName)
|
String |
escapeDataTypeName(String dataTypeName)
|
String |
escapeIndexName(String catalogName,
String schemaName,
String indexName)
|
String |
escapeObjectName(String objectName,
Class<? extends DatabaseObject> objectType)
|
String |
escapeObjectName(String catalogName,
String schemaName,
String objectName,
Class<? extends DatabaseObject> objectType)
|
String |
escapeSequenceName(String catalogName,
String schemaName,
String sequenceName)
|
String |
escapeStringForDatabase(String string)
|
String |
escapeTableName(String catalogName,
String schemaName,
String tableName)
|
String |
escapeViewName(String catalogName,
String schemaName,
String viewName)
|
void |
execute(SqlStatement[] statements,
List<SqlVisitor> sqlVisitors)
|
void |
executeRollbackStatements(Change change,
List<SqlVisitor> sqlVisitors)
|
void |
executeRollbackStatements(SqlStatement[] statements,
List<SqlVisitor> sqlVisitors)
|
void |
executeStatements(Change change,
DatabaseChangeLog changeLog,
List<SqlVisitor> sqlVisitors)
|
String |
generateDatabaseFunctionValue(DatabaseFunction databaseFunction)
Some function names are placeholders that need to be replaced with the specific database value. |
String |
generatePrimaryKeyName(String tableName)
|
boolean |
getAutoCommitMode()
Auto-commit mode to run in |
String |
getAutoIncrementClause(BigInteger startWith,
BigInteger incrementBy)
|
String |
getConcatSql(String... values)
Returns SQL to concat the passed values. |
DatabaseConnection |
getConnection()
|
String |
getCurrentDateTimeFunction()
Returns database-specific function for generating the current date/time. |
String |
getDatabaseChangeLogLockTableName()
|
String |
getDatabaseChangeLogTableName()
|
int |
getDatabaseMajorVersion()
|
int |
getDatabaseMinorVersion()
|
String |
getDatabaseProductName()
|
String |
getDatabaseProductVersion()
|
int |
getDataTypeMaxParameters(String dataTypeName)
|
List<DatabaseFunction> |
getDateFunctions()
Returns list of database native date functions |
String |
getDateLiteral(Date date)
|
String |
getDateLiteral(Date defaultDateValue)
|
String |
getDateLiteral(String isoDate)
|
String |
getDateTimeLiteral(Timestamp timeStamp)
|
String |
getDefaultCatalogName()
|
String |
getDefaultDriver(String url)
If this database understands the given url, return the default driver class name. |
Integer |
getDefaultPort()
|
CatalogAndSchema |
getDefaultSchema()
|
String |
getDefaultSchemaName()
|
String |
getLineComment()
|
String |
getLiquibaseCatalogName()
|
String |
getLiquibaseSchemaName()
|
String |
getLiquibaseTablespaceName()
|
ObjectQuotingStrategy |
getObjectQuotingStrategy()
|
boolean |
getOutputDefaultCatalog()
|
boolean |
getOutputDefaultSchema()
|
RanChangeSet |
getRanChangeSet(ChangeSet changeSet)
|
List<RanChangeSet> |
getRanChangeSetList()
|
Date |
getRanDate(ChangeSet changeSet)
|
ChangeSet.RunStatus |
getRunStatus(ChangeSet changeSet)
|
String |
getShortName()
Returns an all-lower-case short name of the product. |
String |
getSystemSchema()
|
String |
getTimeLiteral(Time time)
|
String |
getViewDefinition(CatalogAndSchema schema,
String name)
|
boolean |
isAutoCommit()
|
boolean |
isCaseSensitive()
|
boolean |
isCorrectDatabaseImplementation(DatabaseConnection conn)
Is this AbstractDatabase subclass the correct one to use for the given connection. |
boolean |
isDefaultCatalog(String catalog)
|
boolean |
isDefaultSchema(String catalog,
String schema)
|
boolean |
isFunction(String string)
|
boolean |
isLiquibaseObject(DatabaseObject object)
|
boolean |
isReservedWord(String string)
|
boolean |
isSafeToRunUpdate()
|
boolean |
isSystemObject(DatabaseObject example)
|
void |
markChangeSetExecStatus(ChangeSet changeSet,
ChangeSet.ExecType execType)
|
Date |
parseDate(String dateAsString)
|
void |
removeRanStatus(ChangeSet changeSet)
|
boolean |
requiresPassword()
|
boolean |
requiresUsername()
|
void |
resetInternalState()
|
void |
rollback()
|
void |
saveRollbackStatement(Change change,
List<SqlVisitor> sqlVisitors,
Writer writer)
|
void |
saveStatements(Change change,
List<SqlVisitor> sqlVisitors,
Writer writer)
|
void |
setAutoCommit(boolean b)
|
void |
setCanCacheLiquibaseTableInfo(boolean canCacheLiquibaseTableInfo)
|
void |
setConnection(DatabaseConnection conn)
|
void |
setCurrentDateTimeFunction(String function)
|
void |
setDatabaseChangeLogLockTableName(String tableName)
Set the table name of the change log lock to the given table name |
void |
setDatabaseChangeLogTableName(String tableName)
Set the table name of the change log to the given table name |
void |
setDefaultCatalogName(String catalogName)
|
void |
setDefaultSchemaName(String schemaName)
|
void |
setLiquibaseCatalogName(String catalogName)
|
void |
setLiquibaseSchemaName(String schemaName)
|
void |
setLiquibaseTablespaceName(String tablespaceName)
|
void |
setObjectQuotingStrategy(ObjectQuotingStrategy quotingStrategy)
|
void |
setOutputDefaultCatalog(boolean outputDefaultCatalog)
|
void |
setOutputDefaultSchema(boolean outputDefaultSchema)
Whether the default schema should be included in generated SQL |
boolean |
supportsAutoIncrement()
|
boolean |
supportsCatalogInObjectName(Class<? extends DatabaseObject> type)
|
boolean |
supportsCatalogs()
|
boolean |
supportsDDLInTransaction()
Determines if the database supports DDL within a transaction or not. |
boolean |
supportsDropTableCascadeConstraints()
|
boolean |
supportsForeignKeyDisable()
|
boolean |
supportsInitiallyDeferrableColumns()
Returns whether this database support initially deferrable columns. |
boolean |
supportsPrimaryKeyNames()
|
boolean |
supportsRestrictForeignKeys()
|
boolean |
supportsSchemas()
|
boolean |
supportsSequences()
|
boolean |
supportsTablespaces()
|
void |
tag(String tagString)
|
String |
unescapeDataTypeName(String dataTypeName)
|
String |
unescapeDataTypeString(String dataTypeString)
|
databaseChangeLogTableName
static final String databaseChangeLogTableName
databaseChangeLogLockTableName
static final String databaseChangeLogLockTableName
isCorrectDatabaseImplementation
boolean isCorrectDatabaseImplementation(DatabaseConnection conn)
throws DatabaseException
- Is this AbstractDatabase subclass the correct one to use for the given connection.
- Throws:
DatabaseException
getDefaultDriver
String getDefaultDriver(String url)
- If this database understands the given url, return the default driver class name. Otherwise return null.
getConnection
DatabaseConnection getConnection()
setConnection
void setConnection(DatabaseConnection conn)
requiresUsername
boolean requiresUsername()
requiresPassword
boolean requiresPassword()
getAutoCommitMode
boolean getAutoCommitMode()
- Auto-commit mode to run in
supportsDDLInTransaction
boolean supportsDDLInTransaction()
- Determines if the database supports DDL within a transaction or not.
- Returns:
- True if the database supports DDL within a transaction, otherwise false.
getDatabaseProductName
String getDatabaseProductName()
getDatabaseProductVersion
String getDatabaseProductVersion()
throws DatabaseException
- Throws:
DatabaseException
getDatabaseMajorVersion
int getDatabaseMajorVersion()
throws DatabaseException
- Throws:
DatabaseException
getDatabaseMinorVersion
int getDatabaseMinorVersion()
throws DatabaseException
- Throws:
DatabaseException
getShortName
String getShortName()
- Returns an all-lower-case short name of the product. Used for end-user selecting of database type
such as the DBMS precondition.
getDefaultCatalogName
String getDefaultCatalogName()
setDefaultCatalogName
void setDefaultCatalogName(String catalogName)
throws DatabaseException
- Throws:
DatabaseException
getDefaultSchemaName
String getDefaultSchemaName()
setDefaultSchemaName
void setDefaultSchemaName(String schemaName)
throws DatabaseException
- Throws:
DatabaseException
getDefaultPort
Integer getDefaultPort()
getLiquibaseCatalogName
String getLiquibaseCatalogName()
setLiquibaseCatalogName
void setLiquibaseCatalogName(String catalogName)
getLiquibaseSchemaName
String getLiquibaseSchemaName()
setLiquibaseSchemaName
void setLiquibaseSchemaName(String schemaName)
supportsInitiallyDeferrableColumns
boolean supportsInitiallyDeferrableColumns()
- Returns whether this database support initially deferrable columns.
supportsSequences
boolean supportsSequences()
supportsDropTableCascadeConstraints
boolean supportsDropTableCascadeConstraints()
supportsAutoIncrement
boolean supportsAutoIncrement()
getDateLiteral
String getDateLiteral(String isoDate)
getCurrentDateTimeFunction
String getCurrentDateTimeFunction()
- Returns database-specific function for generating the current date/time.
setCurrentDateTimeFunction
void setCurrentDateTimeFunction(String function)
getLineComment
String getLineComment()
getAutoIncrementClause
String getAutoIncrementClause(BigInteger startWith,
BigInteger incrementBy)
getDatabaseChangeLogTableName
String getDatabaseChangeLogTableName()
getDatabaseChangeLogLockTableName
String getDatabaseChangeLogLockTableName()
getLiquibaseTablespaceName
String getLiquibaseTablespaceName()
setLiquibaseTablespaceName
void setLiquibaseTablespaceName(String tablespaceName)
setDatabaseChangeLogTableName
void setDatabaseChangeLogTableName(String tableName)
- Set the table name of the change log to the given table name
- Parameters:
tableName
-
setDatabaseChangeLogLockTableName
void setDatabaseChangeLogLockTableName(String tableName)
- Set the table name of the change log lock to the given table name
- Parameters:
tableName
-
getConcatSql
String getConcatSql(String... values)
- Returns SQL to concat the passed values.
setCanCacheLiquibaseTableInfo
void setCanCacheLiquibaseTableInfo(boolean canCacheLiquibaseTableInfo)
dropDatabaseObjects
void dropDatabaseObjects(CatalogAndSchema schema)
throws LiquibaseException
- Throws:
LiquibaseException
tag
void tag(String tagString)
throws DatabaseException
- Throws:
DatabaseException
doesTagExist
boolean doesTagExist(String tag)
throws DatabaseException
- Throws:
DatabaseException
isSystemObject
boolean isSystemObject(DatabaseObject example)
isLiquibaseObject
boolean isLiquibaseObject(DatabaseObject object)
getViewDefinition
String getViewDefinition(CatalogAndSchema schema,
String name)
throws DatabaseException
- Throws:
DatabaseException
getDateLiteral
String getDateLiteral(Date date)
getTimeLiteral
String getTimeLiteral(Time time)
getDateTimeLiteral
String getDateTimeLiteral(Timestamp timeStamp)
getDateLiteral
String getDateLiteral(Date defaultDateValue)
escapeObjectName
String escapeObjectName(String catalogName,
String schemaName,
String objectName,
Class<? extends DatabaseObject> objectType)
escapeTableName
String escapeTableName(String catalogName,
String schemaName,
String tableName)
escapeIndexName
String escapeIndexName(String catalogName,
String schemaName,
String indexName)
escapeObjectName
String escapeObjectName(String objectName,
Class<? extends DatabaseObject> objectType)
escapeColumnName
String escapeColumnName(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. "return").
- Parameters:
schemaName
- tableName
- columnName
- column name
- Returns:
- escaped column name
escapeColumnName
String escapeColumnName(String catalogName,
String schemaName,
String tableName,
String columnName,
boolean quoteNamesThatMayBeFunctions)
escapeColumnNameList
String 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. "return").
- Parameters:
columnNames
- list of column names
- Returns:
- escaped column name list
supportsTablespaces
boolean supportsTablespaces()
supportsCatalogs
boolean supportsCatalogs()
supportsSchemas
boolean supportsSchemas()
supportsCatalogInObjectName
boolean supportsCatalogInObjectName(Class<? extends DatabaseObject> type)
generatePrimaryKeyName
String generatePrimaryKeyName(String tableName)
escapeSequenceName
String escapeSequenceName(String catalogName,
String schemaName,
String sequenceName)
escapeViewName
String escapeViewName(String catalogName,
String schemaName,
String viewName)
getRunStatus
ChangeSet.RunStatus getRunStatus(ChangeSet changeSet)
throws DatabaseException,
DatabaseHistoryException
- Throws:
DatabaseException
DatabaseHistoryException
getRanChangeSet
RanChangeSet getRanChangeSet(ChangeSet changeSet)
throws DatabaseException,
DatabaseHistoryException
- Throws:
DatabaseException
DatabaseHistoryException
markChangeSetExecStatus
void markChangeSetExecStatus(ChangeSet changeSet,
ChangeSet.ExecType execType)
throws DatabaseException
- Throws:
DatabaseException
getRanChangeSetList
List<RanChangeSet> getRanChangeSetList()
throws DatabaseException
- Throws:
DatabaseException
getRanDate
Date getRanDate(ChangeSet changeSet)
throws DatabaseException,
DatabaseHistoryException
- Throws:
DatabaseException
DatabaseHistoryException
removeRanStatus
void removeRanStatus(ChangeSet changeSet)
throws DatabaseException
- Throws:
DatabaseException
commit
void commit()
throws DatabaseException
- Throws:
DatabaseException
rollback
void rollback()
throws DatabaseException
- Throws:
DatabaseException
escapeStringForDatabase
String escapeStringForDatabase(String string)
close
void close()
throws DatabaseException
- Throws:
DatabaseException
supportsRestrictForeignKeys
boolean supportsRestrictForeignKeys()
escapeConstraintName
String escapeConstraintName(String constraintName)
isAutoCommit
boolean isAutoCommit()
throws DatabaseException
- Throws:
DatabaseException
setAutoCommit
void setAutoCommit(boolean b)
throws DatabaseException
- Throws:
DatabaseException
isSafeToRunUpdate
boolean isSafeToRunUpdate()
throws DatabaseException
- Throws:
DatabaseException
executeStatements
void executeStatements(Change change,
DatabaseChangeLog changeLog,
List<SqlVisitor> sqlVisitors)
throws LiquibaseException
- Throws:
LiquibaseException
execute
void execute(SqlStatement[] statements,
List<SqlVisitor> sqlVisitors)
throws LiquibaseException
- Throws:
LiquibaseException
saveStatements
void saveStatements(Change change,
List<SqlVisitor> sqlVisitors,
Writer writer)
throws IOException,
StatementNotSupportedOnDatabaseException,
LiquibaseException
- Throws:
IOException
StatementNotSupportedOnDatabaseException
LiquibaseException
executeRollbackStatements
void executeRollbackStatements(Change change,
List<SqlVisitor> sqlVisitors)
throws LiquibaseException,
RollbackImpossibleException
- Throws:
LiquibaseException
RollbackImpossibleException
executeRollbackStatements
void executeRollbackStatements(SqlStatement[] statements,
List<SqlVisitor> sqlVisitors)
throws LiquibaseException,
RollbackImpossibleException
- Throws:
LiquibaseException
RollbackImpossibleException
saveRollbackStatement
void saveRollbackStatement(Change change,
List<SqlVisitor> sqlVisitors,
Writer writer)
throws IOException,
RollbackImpossibleException,
StatementNotSupportedOnDatabaseException,
LiquibaseException
- Throws:
IOException
RollbackImpossibleException
StatementNotSupportedOnDatabaseException
LiquibaseException
parseDate
Date parseDate(String dateAsString)
throws DateParseException
- Throws:
DateParseException
getDateFunctions
List<DatabaseFunction> getDateFunctions()
- Returns list of database native date functions
resetInternalState
void resetInternalState()
supportsForeignKeyDisable
boolean supportsForeignKeyDisable()
disableForeignKeyChecks
boolean disableForeignKeyChecks()
throws DatabaseException
- Throws:
DatabaseException
enableForeignKeyChecks
void enableForeignKeyChecks()
throws DatabaseException
- Throws:
DatabaseException
isCaseSensitive
boolean isCaseSensitive()
isReservedWord
boolean isReservedWord(String string)
correctSchema
CatalogAndSchema correctSchema(CatalogAndSchema schema)
- Deprecated. use
CatalogAndSchema.standardize(Database)
- 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
correctObjectName
String correctObjectName(String name,
Class<? extends DatabaseObject> objectType)
- Fix the object name to the format the database expects, handling changes in case, etc.
isFunction
boolean isFunction(String string)
getDataTypeMaxParameters
int getDataTypeMaxParameters(String dataTypeName)
getDefaultSchema
CatalogAndSchema getDefaultSchema()
dataTypeIsNotModifiable
boolean dataTypeIsNotModifiable(String typeName)
- Types 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
generateDatabaseFunctionValue
String generateDatabaseFunctionValue(DatabaseFunction databaseFunction)
- Some 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
setObjectQuotingStrategy
void setObjectQuotingStrategy(ObjectQuotingStrategy quotingStrategy)
getObjectQuotingStrategy
ObjectQuotingStrategy getObjectQuotingStrategy()
createsIndexesForForeignKeys
boolean createsIndexesForForeignKeys()
setOutputDefaultSchema
void setOutputDefaultSchema(boolean outputDefaultSchema)
- Whether the default schema should be included in generated SQL
getOutputDefaultSchema
boolean getOutputDefaultSchema()
isDefaultSchema
boolean isDefaultSchema(String catalog,
String schema)
isDefaultCatalog
boolean isDefaultCatalog(String catalog)
getOutputDefaultCatalog
boolean getOutputDefaultCatalog()
setOutputDefaultCatalog
void setOutputDefaultCatalog(boolean outputDefaultCatalog)
supportsPrimaryKeyNames
boolean supportsPrimaryKeyNames()
getSystemSchema
String getSystemSchema()
addReservedWords
void addReservedWords(Collection<String> words)
escapeDataTypeName
String escapeDataTypeName(String dataTypeName)
unescapeDataTypeName
String unescapeDataTypeName(String dataTypeName)
unescapeDataTypeString
String unescapeDataTypeString(String dataTypeString)
Copyright © 2015 Liquibase.org. All rights reserved.