org.dbmaintain.database.impl
Class OracleDatabase

java.lang.Object
  extended by org.dbmaintain.database.Database
      extended by org.dbmaintain.database.impl.OracleDatabase

public class OracleDatabase
extends Database

Implementation of Database for an Oracle database.

Author:
Filip Neven, Tim Ducheyne

Field Summary
 
Fields inherited from class org.dbmaintain.database.Database
databaseConnection, identifierProcessor, schemaNames
 
Constructor Summary
OracleDatabase(DatabaseConnection databaseConnection, IdentifierProcessor identifierProcessor)
           
 
Method Summary
 void disableReferentialConstraints(String schemaName)
          Disables all referential constraints (e.g. foreign keys) on all table in the schema
 void disableValueConstraints(String schemaName)
          Disables all value constraints (e.g. not null) on all tables in the schema
 void dropMaterializedView(String schemaName, String materializedViewName)
          Removes the materialized view with the given name from the database Note: the view name is surrounded with quotes, making it case-sensitive.
 void dropTable(String schemaName, String tableName)
          Removes the table with the given name from the database.
 void dropType(String schemaName, String typeName)
          Drops the type with the given name from the database Note: the type name is surrounded with quotes, making it case-sensitive.
 void dropView(String schemaName, String viewName)
          Removes the view with the given name from the database Note: the view name is surrounded with quotes, making it case-sensitive.
 Set<String> getColumnNames(String schemaName, String tableName)
          Gets the names of all columns of the given table.
 String getLongDataType()
          Gets the column type suitable to store values of the Java java.lang.Long type.
 Set<String> getMaterializedViewNames(String schemaName)
          Retrieves the names of all materialized views in the database schema.
protected  Integer getOracleMajorVersionNumber()
           
 Set<String> getSequenceNames(String schemaName)
          Retrieves the names of all sequences in the database schema.
 long getSequenceValue(String schemaName, String sequenceName)
          Returns the value of the sequence with the given name.
 String getSupportedDatabaseDialect()
           
 Set<String> getSynonymNames(String schemaName)
          Retrieves the names of all synonyms in the database schema.
 Set<String> getTableNames(String schemaName)
          Returns the names of all tables in the database.
 String getTextDataType(int length)
          Gets the column type suitable to store text values.
 Set<String> getTriggerNames(String schemaName)
          Retrieves the names of all triggers in the database schema.
 Set<String> getTypeNames(String schemaName)
          Retrieves the names of all the types in the database schema.
 Set<String> getViewNames(String schemaName)
          Retrieves the names of all views in the database schema.
 void incrementSequenceToValue(String schemaName, String sequenceName, long newSequenceValue)
          Sets the next value of the sequence with the given sequence name to the given sequence value.
 void setDatabaseDefaultSchema()
          Sets the current schema of the database.
 boolean supportsCascade()
          Cascade are supported.
 boolean supportsMaterializedViews()
          Materialized views are supported
protected  boolean supportsPurge()
           
 boolean supportsSequences()
          Sequences are supported.
 boolean supportsSetDatabaseDefaultSchema()
          Setting the default schema is supported.
 boolean supportsSynonyms()
          Synonyms are supported
 boolean supportsTriggers()
          Triggers are supported.
 boolean supportsTypes()
          Types are supported
 
Methods inherited from class org.dbmaintain.database.Database
disableReferentialConstraints, disableValueConstraints, dropMaterializedView, dropRule, dropSequence, dropSequence, dropStoredProcedure, dropStoredProcedure, dropSynonym, dropSynonym, dropTable, dropTrigger, dropTrigger, dropType, dropView, getColumnNames, getDatabaseInfo, getDatabaseName, getDataSource, getDefaultSchemaName, getIdentifierQuoteString, getIdentityColumnNames, getIdentityColumnNames, getMaterializedViewNames, getRuleNames, getSchemaNames, getSequenceNames, getSequenceValue, getSQLHandler, getStoredIdentifierCase, getStoredProcedureNames, getStoredProcedureNames, getSynonymNames, getTableNames, getTriggerNames, getTypeNames, getViewNames, incrementIdentityColumnToValue, incrementIdentityColumnToValue, incrementSequenceToValue, isQuoted, qualified, qualified, quoted, removeIdentifierQuotes, setSettingIdentityColumnValueEnabled, setSettingIdentityColumnValueEnabled, supportsIdentityColumns, supportsRules, supportsStoredProcedures, toCorrectCaseIdentifier
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OracleDatabase

public OracleDatabase(DatabaseConnection databaseConnection,
                      IdentifierProcessor identifierProcessor)
Method Detail

getSupportedDatabaseDialect

public String getSupportedDatabaseDialect()
Specified by:
getSupportedDatabaseDialect in class Database
Returns:
the database dialect supported by this db support class, not null

getTableNames

public Set<String> getTableNames(String schemaName)
Returns the names of all tables in the database.

Specified by:
getTableNames in class Database
Parameters:
schemaName - The schema, not null
Returns:
The names of all tables in the database

getColumnNames

public Set<String> getColumnNames(String schemaName,
                                  String tableName)
Gets the names of all columns of the given table.

Specified by:
getColumnNames in class Database
Parameters:
tableName - The table, not null
schemaName - The schema, not null
Returns:
The names of the columns of the table with the given name

getViewNames

public Set<String> getViewNames(String schemaName)
Retrieves the names of all views in the database schema.

Specified by:
getViewNames in class Database
Parameters:
schemaName - The schema, not null
Returns:
The names of all views in the database

getMaterializedViewNames

public Set<String> getMaterializedViewNames(String schemaName)
Retrieves the names of all materialized views in the database schema.

Overrides:
getMaterializedViewNames in class Database
Parameters:
schemaName - The schema, not null
Returns:
The names of all materialized views in the database

getSynonymNames

public Set<String> getSynonymNames(String schemaName)
Retrieves the names of all synonyms in the database schema.

Overrides:
getSynonymNames in class Database
Parameters:
schemaName - The schema, not null
Returns:
The names of all synonyms in the database

getSequenceNames

public Set<String> getSequenceNames(String schemaName)
Retrieves the names of all sequences in the database schema.

Overrides:
getSequenceNames in class Database
Parameters:
schemaName - The schema, not null
Returns:
The names of all sequences in the database

getTriggerNames

public Set<String> getTriggerNames(String schemaName)
Retrieves the names of all triggers in the database schema.

Overrides:
getTriggerNames in class Database
Parameters:
schemaName - The schema, not null
Returns:
The names of all triggers in the database

getTypeNames

public Set<String> getTypeNames(String schemaName)
Retrieves the names of all the types in the database schema.

Overrides:
getTypeNames in class Database
Parameters:
schemaName - The schema, not null
Returns:
The names of all types in the database

dropTable

public void dropTable(String schemaName,
                      String tableName)
Removes the table with the given name from the database. Note: the table name is surrounded with quotes, making it case-sensitive.

Overrides:
dropTable in class Database
Parameters:
tableName - The table to drop (case-sensitive), not null
schemaName - The schema, not null

dropView

public void dropView(String schemaName,
                     String viewName)
Removes the view with the given name from the database Note: the view name is surrounded with quotes, making it case-sensitive.

Overrides:
dropView in class Database
Parameters:
viewName - The view to drop (case-sensitive), not null
schemaName - The schema, not null

dropMaterializedView

public void dropMaterializedView(String schemaName,
                                 String materializedViewName)
Removes the materialized view with the given name from the database Note: the view name is surrounded with quotes, making it case-sensitive.

Overrides:
dropMaterializedView in class Database
Parameters:
materializedViewName - The view to drop (case-sensitive), not null
schemaName - The schema, not null

dropType

public void dropType(String schemaName,
                     String typeName)
Drops the type with the given name from the database Note: the type name is surrounded with quotes, making it case-sensitive.

Overriden to add the force option. This will make sure that super-types can also be dropped.

Overrides:
dropType in class Database
Parameters:
typeName - The type to drop (case-sensitive), not null
schemaName - The schema, not null

disableReferentialConstraints

public void disableReferentialConstraints(String schemaName)
Disables all referential constraints (e.g. foreign keys) on all table in the schema

Specified by:
disableReferentialConstraints in class Database
Parameters:
schemaName - The schema, not null

disableValueConstraints

public void disableValueConstraints(String schemaName)
Disables all value constraints (e.g. not null) on all tables in the schema

Specified by:
disableValueConstraints in class Database
Parameters:
schemaName - The schema, not null

getSequenceValue

public long getSequenceValue(String schemaName,
                             String sequenceName)
Returns the value of the sequence with the given name.

Note: this can have the side-effect of increasing the sequence value.

Overrides:
getSequenceValue in class Database
Parameters:
sequenceName - The sequence, not null
schemaName - The schema, not null
Returns:
The value of the sequence with the given name

incrementSequenceToValue

public void incrementSequenceToValue(String schemaName,
                                     String sequenceName,
                                     long newSequenceValue)
Sets the next value of the sequence with the given sequence name to the given sequence value.

Overrides:
incrementSequenceToValue in class Database
Parameters:
sequenceName - The sequence, not null
newSequenceValue - The value to set
schemaName - The schema, not null

setDatabaseDefaultSchema

public void setDatabaseDefaultSchema()
Sets the current schema of the database. If a current schema is set, it does not need to be specified explicitly in the scripts.

Overrides:
setDatabaseDefaultSchema in class Database

getLongDataType

public String getLongDataType()
Gets the column type suitable to store values of the Java java.lang.Long type.

Overrides:
getLongDataType in class Database
Returns:
The column type

getTextDataType

public String getTextDataType(int length)
Gets the column type suitable to store text values.

Overrides:
getTextDataType in class Database
Parameters:
length - The nr of characters.
Returns:
The column type, not null

supportsSynonyms

public boolean supportsSynonyms()
Synonyms are supported

Overrides:
supportsSynonyms in class Database
Returns:
True

supportsSequences

public boolean supportsSequences()
Sequences are supported.

Overrides:
supportsSequences in class Database
Returns:
True

supportsTriggers

public boolean supportsTriggers()
Triggers are supported.

Overrides:
supportsTriggers in class Database
Returns:
True

supportsTypes

public boolean supportsTypes()
Types are supported

Overrides:
supportsTypes in class Database
Returns:
true

supportsMaterializedViews

public boolean supportsMaterializedViews()
Materialized views are supported

Overrides:
supportsMaterializedViews in class Database
Returns:
true

supportsCascade

public boolean supportsCascade()
Cascade are supported.

Overrides:
supportsCascade in class Database
Returns:
True

supportsSetDatabaseDefaultSchema

public boolean supportsSetDatabaseDefaultSchema()
Setting the default schema is supported.

Overrides:
supportsSetDatabaseDefaultSchema in class Database
Returns:
True

supportsPurge

protected boolean supportsPurge()
Returns:
Whether or not this version of the Oracle database that is used supports the purge keyword. This is, whether or not an Oracle database of version 10 or higher is used.

getOracleMajorVersionNumber

protected Integer getOracleMajorVersionNumber()
Returns:
The major version number of the Oracle database server that is used (e.g. for Oracle version 9.2.0.1, 9 is returned


Copyright © 2011. All Rights Reserved.