ca.sqlpower.architect.ddl
Class OracleDDLGenerator

java.lang.Object
  extended by ca.sqlpower.architect.ddl.GenericDDLGenerator
      extended by ca.sqlpower.architect.ddl.OracleDDLGenerator
All Implemented Interfaces:
DDLGenerator

public class OracleDDLGenerator
extends GenericDDLGenerator


Field Summary
static java.lang.String GENERATOR_VERSION
           
 
Fields inherited from class ca.sqlpower.architect.ddl.GenericDDLGenerator
allowConnection, con, EOL, profileFunctionMap, targetCatalog, targetSchema, topLevelNames, typeMap, warnings
 
Constructor Summary
OracleDDLGenerator()
           
 
Method Summary
 void addColumn(SQLColumn c)
          Different from the generic generator because the "COLUMN" keyword is forbidden in Oracle.
 void addIndex(SQLIndex index)
          create index ddl in oracle syntax
 void addTable(SQLTable t)
          Overridden to also create sequences if there are auto-increment columns in the table.
protected  void createTypeMap()
          Creates and populates typeMap using DatabaseMetaData.
 java.lang.String getCatalogTerm()
          Returns null because Oracle doesn't have catalogs.
 java.lang.String getDeleteActionClause(SQLRelationship r)
          Returns the ON DELETE clause for the given relationship, with no extra whitespace or newline characters around it.
 java.lang.String getName()
          Returns the name of this DDL Generator, which should be a human-readable string with the vendor and/or product name (and version if the generator doesn't work with all versions) of the database platform this generator targets.
 java.lang.String getSchemaTerm()
          Returns the string "Schema".
 java.lang.String getUpdateActionClause(SQLRelationship r)
          Only returns the empty string for supported update actions (see supportsUpdateAction(SQLRelationship)), and throws an IllegalArgumentException if the update rule is not supported.
 boolean isReservedWord(java.lang.String word)
          Subroutine for toIdentifier().
 java.lang.String makeDropForeignKeySQL(java.lang.String fkTable, java.lang.String fkName)
          Generates a command for dropping a foreign key on oracle.
 void modifyColumn(SQLColumn c)
          Different from the generic generator because Oracle requires the non-standard keyword "MODIFY" instead of "ALTER COLUMN".
 boolean supportsDeleteAction(SQLRelationship r)
          Returns true if this DDL generator supports the given relationship's delete action.
 boolean supportsRollback()
          The generic DDL generator claims to support rollback operation, so specific platforms that don't support it should override this method.
 boolean supportsUpdateAction(SQLRelationship r)
          Oracle does not support any explicit ON UPDATE clause in FK constraints, but the default behaviour is basically the same as NO ACTION or RESTRICT of other platforms.
 java.lang.String toIdentifier(java.lang.String name)
          Converts space to underscore in name and returns the possibly-modified string.
 void writeHeader()
           
 
Methods inherited from class ca.sqlpower.architect.ddl.GenericDDLGenerator
addPrimaryKey, addPrimaryKeysToCreateTable, addRelationship, columnDefinition, columnNullability, columnType, createPhysicalName, createSeqPhysicalName, dropColumn, dropPrimaryKey, dropRelationship, dropTable, endStatement, failsafeGetTypeDescriptor, generateDDLScript, generateDDLStatements, getAllowConnection, getColumnDataTypeName, getCon, getDdlStatements, getDefaultType, getDeferrabilityClause, getProfileFunctionMap, getStatementTerminator, getTargetCatalog, getTargetSchema, getTypeMap, getWarnings, makeDropTableSQL, print, println, setAllowConnection, setCon, setProfileFunctionMap, setTargetCatalog, setTargetSchema, setTypeMap, supportsDeferrabilityPolicy, toQualifiedName, toQualifiedName, toQualifiedName, writeCreateDB, writeDDLTransactionBegin, writeDDLTransactionEnd, writeExportedRelationships, writePrimaryKey
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GENERATOR_VERSION

public static final java.lang.String GENERATOR_VERSION
See Also:
Constant Field Values
Constructor Detail

OracleDDLGenerator

public OracleDDLGenerator()
                   throws java.sql.SQLException
Throws:
java.sql.SQLException
Method Detail

getName

public java.lang.String getName()
Description copied from interface: DDLGenerator
Returns the name of this DDL Generator, which should be a human-readable string with the vendor and/or product name (and version if the generator doesn't work with all versions) of the database platform this generator targets.

Specified by:
getName in interface DDLGenerator
Overrides:
getName in class GenericDDLGenerator

writeHeader

public void writeHeader()
Overrides:
writeHeader in class GenericDDLGenerator

createTypeMap

protected void createTypeMap()
                      throws java.sql.SQLException
Description copied from class: GenericDDLGenerator
Creates and populates typeMap using DatabaseMetaData. Subclasses for specific DB platforms will be able to override this implementation with one that uses a static, pre-defined type map.

Overrides:
createTypeMap in class GenericDDLGenerator
Throws:
java.sql.SQLException

isReservedWord

public boolean isReservedWord(java.lang.String word)
Subroutine for toIdentifier(). Probably a generally useful feature that we should pull up to the GenericDDLGenerator.

Specified by:
isReservedWord in interface DDLGenerator
Overrides:
isReservedWord in class GenericDDLGenerator
Returns:

toIdentifier

public java.lang.String toIdentifier(java.lang.String name)
Description copied from class: GenericDDLGenerator
Converts space to underscore in name and returns the possibly-modified string. This will not be completely sufficient because it leaves ".", "%", and lots of other non-alphanumeric characters alone. Subclasses might choose to quote and leave everything alone, or whatever.

Specified by:
toIdentifier in interface DDLGenerator
Overrides:
toIdentifier in class GenericDDLGenerator

getCatalogTerm

public java.lang.String getCatalogTerm()
Returns null because Oracle doesn't have catalogs.

Specified by:
getCatalogTerm in interface DDLGenerator
Overrides:
getCatalogTerm in class GenericDDLGenerator

getSchemaTerm

public java.lang.String getSchemaTerm()
Returns the string "Schema".

Specified by:
getSchemaTerm in interface DDLGenerator
Overrides:
getSchemaTerm in class GenericDDLGenerator

makeDropForeignKeySQL

public java.lang.String makeDropForeignKeySQL(java.lang.String fkTable,
                                              java.lang.String fkName)
Generates a command for dropping a foreign key on oracle. The statement looks like ALTER TABLE $fktable DROP CONSTRAINT $fkname.

Specified by:
makeDropForeignKeySQL in interface DDLGenerator
Overrides:
makeDropForeignKeySQL in class GenericDDLGenerator
Parameters:
fkTable - The name of the FK table whose relationship should be dropped.
fkName - The name of the key to drop.
Returns:
a SQL statement which will drop the key.

modifyColumn

public void modifyColumn(SQLColumn c)
Different from the generic generator because Oracle requires the non-standard keyword "MODIFY" instead of "ALTER COLUMN".

Specified by:
modifyColumn in interface DDLGenerator
Overrides:
modifyColumn in class GenericDDLGenerator
Parameters:
c - The column to create a MODIFY or ALTER COLUMN statement for.

addColumn

public void addColumn(SQLColumn c)
Different from the generic generator because the "COLUMN" keyword is forbidden in Oracle.

Specified by:
addColumn in interface DDLGenerator
Overrides:
addColumn in class GenericDDLGenerator
Parameters:
c - The column to create a ADD statement for.

addIndex

public void addIndex(SQLIndex index)
              throws ArchitectException
create index ddl in oracle syntax

Specified by:
addIndex in interface DDLGenerator
Overrides:
addIndex in class GenericDDLGenerator
Parameters:
index - The specification of the index to create. Note, if the index type is STATISTIC, no DDL will be generated because STATISTIC indices are just artificial JDBC constructs to describe table statistics (you can't create or drop them).
Throws:
ArchitectException

addTable

public void addTable(SQLTable t)
              throws java.sql.SQLException,
                     ArchitectException
Overridden to also create sequences if there are auto-increment columns in the table.

Specified by:
addTable in interface DDLGenerator
Overrides:
addTable in class GenericDDLGenerator
Throws:
java.sql.SQLException
ArchitectException

supportsDeleteAction

public boolean supportsDeleteAction(SQLRelationship r)
Description copied from class: GenericDDLGenerator
Returns true if this DDL generator supports the given relationship's delete action. The generic DDL generator claims to support all delete actions, so specific platforms that don't support all delete actions should override this method.

Overrides:
supportsDeleteAction in class GenericDDLGenerator

getDeleteActionClause

public java.lang.String getDeleteActionClause(SQLRelationship r)
Description copied from class: GenericDDLGenerator
Returns the ON DELETE clause for the given relationship, with no extra whitespace or newline characters around it.

If you are overriding this method for a platform-specific DDL generator and you need this clause to be empty, return the empty string--not null.

Overrides:
getDeleteActionClause in class GenericDDLGenerator
Parameters:
r - The relationship whose delete action clause to generate
Returns:
The delete action clause

supportsUpdateAction

public boolean supportsUpdateAction(SQLRelationship r)
Oracle does not support any explicit ON UPDATE clause in FK constraints, but the default behaviour is basically the same as NO ACTION or RESTRICT of other platforms. So this method claims those rules are supported, but the others are not.

Overrides:
supportsUpdateAction in class GenericDDLGenerator

getUpdateActionClause

public java.lang.String getUpdateActionClause(SQLRelationship r)
Only returns the empty string for supported update actions (see supportsUpdateAction(SQLRelationship)), and throws an IllegalArgumentException if the update rule is not supported.

Overrides:
getUpdateActionClause in class GenericDDLGenerator
Parameters:
r - The relationship whose update action clause to generate
Returns:
The update action clause

supportsRollback

public boolean supportsRollback()
Description copied from class: GenericDDLGenerator
The generic DDL generator claims to support rollback operation, so specific platforms that don't support it should override this method.

Specified by:
supportsRollback in interface DDLGenerator
Overrides:
supportsRollback in class GenericDDLGenerator


Copyright © 2003-2007 SQL Power Group Inc. www.sqlpower.ca