ca.sqlpower.architect.ddl
Class GenericDDLGenerator

java.lang.Object
  extended by ca.sqlpower.architect.ddl.GenericDDLGenerator
All Implemented Interfaces:
DDLGenerator
Direct Known Subclasses:
DB2DDLGenerator, HSQLDBDDLGenerator, MySqlDDLGenerator, OracleDDLGenerator, PostgresDDLGenerator, SQLServerDDLGenerator

public class GenericDDLGenerator
extends java.lang.Object
implements DDLGenerator


Field Summary
protected  boolean allowConnection
          This property says whether or not the user will allow us to connect to the target system in order to determine database meta-data.
protected  java.sql.Connection con
          This variable will be a live, non-null connection to the target database (set up by writeDDL) if allowConnection is true.
protected static java.lang.String EOL
          This is initialized to the System line.separator property.
static java.lang.String GENERATOR_VERSION
           
protected  java.util.Map<java.lang.String,ProfileFunctionDescriptor> profileFunctionMap
          A mapping from JDBC type code (Integer values) to appliable profile functions (min,max,avg,sum,etc...)
protected  java.lang.String targetCatalog
          The name of the catalog in the target database that the generated DDL statements should create the objects in.
protected  java.lang.String targetSchema
          The name of the schema in the target database that the generated DDL statements should create the objects in.
protected  java.util.Map<java.lang.String,SQLObject> topLevelNames
          As table and relationship creation statements are generated, their SQL identifiers are stored in this map (key is name, value is object having that name).
protected  java.util.Map typeMap
          A mapping from JDBC type code (Integer values) to GenericTypeDescriptor objects which describe that data type.
protected  java.util.List warnings
          This list contains 0 or more NameChangeWarning objects.
 
Constructor Summary
GenericDDLGenerator()
           
 
Method Summary
 void addColumn(SQLColumn c)
          Appends the DDL statement for adding the given column to its parent table in this DDL Generator's target schema/catalog.
 void addIndex(SQLIndex index)
          Adds a DDL statement to this generator that will create the given index.
 void addPrimaryKey(SQLTable t)
           
protected  void addPrimaryKeysToCreateTable(SQLTable t)
           
 void addRelationship(SQLRelationship r)
          Adds a statement for creating the given foreign key relationship in the target database.
 void addTable(SQLTable t)
          Appends the DDL statements for creating a table in this DDL Generator's current catalog and schema using SQLTable t as a template.
protected  java.lang.String columnDefinition(SQLColumn c, java.util.Map colNameMap)
          Creates a SQL DDL snippet which consists of the column name, data type, default value, and nullability clauses.
protected  java.lang.String columnNullability(SQLColumn c)
           
 java.lang.String columnType(SQLColumn c)
          Columnn type
protected  java.lang.String createPhysicalName(java.util.Map<java.lang.String,SQLObject> dupCheck, SQLObject so)
          Generate, set, and return a valid identifier for this SQLObject.
protected  java.lang.String createSeqPhysicalName(java.util.Map<java.lang.String,SQLObject> dupCheck, SQLSequence seq, SQLColumn col)
          Generate, set, and return a valid identifier for this SQLSequence.
protected  void createTypeMap()
          Creates and populates typeMap using DatabaseMetaData.
 void dropColumn(SQLColumn c)
          Appends the DDL statement for dropping the given column from its parent table in this DDL Generator's target schema/catalog.
 void dropPrimaryKey(SQLTable t)
           
 void dropRelationship(SQLRelationship r)
          Appends the DDL statement for dropping the given FK relationship in this DDL Generator's target schema/catalog.
 void dropTable(SQLTable t)
          Appends the DDL statements for dropping the table in this DDL Generator's current catalog and schema using SQLTable t's physical name.
 void endStatement(DDLStatement.StatementType type, SQLObject sqlObject)
          Stores all the ddl since the last call to endStatement as a SQL statement.
protected  GenericTypeDescriptor failsafeGetTypeDescriptor(SQLColumn c)
          Returns the type descriptor for the given column's type if that exists in this generator's typemap, else returns the default type.
 java.lang.String generateDDLScript(java.util.Collection<SQLTable> tables)
          Generates the series of DDL Statements as in DDLGenerator.generateDDLStatements(Collection), then compiles them into a formatted script complete with statement terminators and transaction start and end statements (if supported by the target platform).
 java.util.List<DDLStatement> generateDDLStatements(java.util.Collection<SQLTable> tables)
          Creates a series of SQL DDL statements which will create the given list of tables in a target database.
 boolean getAllowConnection()
          Gets the value of allowConnection
 java.lang.String getCatalogTerm()
          The name that the target database gives to the JDBC idea of "catalog." For Oracle, this would be null (no catalogs) and for SQL Server it would be "Database".
 java.lang.String getColumnDataTypeName(SQLColumn c)
          Columnn type
 java.sql.Connection getCon()
          Gets the value of con
 java.util.List<DDLStatement> getDdlStatements()
          Returns the list of DDL statements that have been created so far.
protected  java.lang.Object getDefaultType()
          Returns the default data type for this platform.
 java.lang.String getDeferrabilityClause(SQLRelationship r)
          Returns the correct syntax for setting the deferrability of a foreign key relationship on this DDL Generator's target platform.
 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.util.Map<java.lang.String,ProfileFunctionDescriptor> getProfileFunctionMap()
           
 java.lang.String getSchemaTerm()
          The name that the target database gives to the JDBC idea of "schema." For Oracle, this would be "Schema" and for SQL Server it would be "Owner".
 java.lang.String getStatementTerminator()
          Prints a single semicolon character (no newline).
 java.lang.String getTargetCatalog()
          See targetCatalog.
 java.lang.String getTargetSchema()
          See targetSchema.
 java.util.Map getTypeMap()
          Gets the value of typeMap
 java.lang.String getUpdateActionClause(SQLRelationship r)
          Returns the ON UPDATE clause for the given relationship, with no extra whitespace or newline characters around it.
 java.util.List getWarnings()
          Returns warnings.
 boolean isReservedWord(java.lang.String word)
          Check to see if the word word is on the list of reserved words for this database
 java.lang.String makeDropForeignKeySQL(java.lang.String fkTable, java.lang.String fkName)
          Generates a command for dropping a foreign key which works on some platforms.
 java.lang.String makeDropTableSQL(java.lang.String table)
          Generates a standard DROP TABLE $tablename command.
 void modifyColumn(SQLColumn c)
          Appends the DDL statement for modifying the given column's datatype and nullability in its parent table in this DDL Generator's target schema/catalog.
protected  void print(java.lang.String text)
           
protected  void println(java.lang.String text)
           
 void setAllowConnection(boolean argAllowConnection)
          Sets the value of allowConnection
 void setCon(java.sql.Connection argCon)
          Sets the value of con
 void setProfileFunctionMap(java.util.Map profileFunctionMap)
           
 void setTargetCatalog(java.lang.String argTargetCatalog)
          See targetCatalog.
 void setTargetSchema(java.lang.String argTargetSchema)
          See targetSchema.
 void setTypeMap(java.util.Map argTypeMap)
          Sets the value of typeMap
 boolean supportsDeferrabilityPolicy(SQLRelationship r)
          Returns true if the platform supports the deferrability policy of the given relationship, false otherwise.
 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)
          Returns true if this DDL generator supports the given relationship's update action.
 java.lang.String toIdentifier(java.lang.String name)
          Converts space to underscore in name and returns the possibly-modified string.
 java.lang.String toQualifiedName(SQLIndex i)
          Creates a qualified name from the physical name of the SQLIndex
 java.lang.String toQualifiedName(SQLTable t)
          Creates a fully-qualified table name from the given table's phyiscal name and this DDL Generator's current target schema and catalog.
 java.lang.String toQualifiedName(java.lang.String tname)
          Creates a fully-qualified table name from the given string (which is the non-qualified table name) and this DDL Generator's current target schema and catalog.
 void writeCreateDB(SQLDatabase db)
           
 void writeDDLTransactionBegin()
          Does nothing.
 void writeDDLTransactionEnd()
          Does nothing.
protected  void writeExportedRelationships(SQLTable t)
          Adds statements for creating every exported key in the given table.
 void writeHeader()
           
protected  void writePrimaryKey(SQLTable t)
           
 
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

allowConnection

protected boolean allowConnection
This property says whether or not the user will allow us to connect to the target system in order to determine database meta-data. This generic base class will fail if allowConnection == false.


EOL

protected static final java.lang.String EOL
This is initialized to the System line.separator property.


typeMap

protected java.util.Map typeMap
A mapping from JDBC type code (Integer values) to GenericTypeDescriptor objects which describe that data type.


con

protected java.sql.Connection con
This variable will be a live, non-null connection to the target database (set up by writeDDL) if allowConnection is true.


topLevelNames

protected java.util.Map<java.lang.String,SQLObject> topLevelNames
As table and relationship creation statements are generated, their SQL identifiers are stored in this map (key is name, value is object having that name). Warnings are created when multiple objects in this top-level scope use the same name. XXX Consider changing this to a Set as it appears that the values stored in the Map are never used.


warnings

protected java.util.List warnings
This list contains 0 or more NameChangeWarning objects. It is populated as statements are added to the ddlStatements list. If non-empty, this list of warnings should be presented to the user before the generated DDL is saved or executed (to give them a chance to fix the warnings and try again).


targetCatalog

protected java.lang.String targetCatalog
The name of the catalog in the target database that the generated DDL statements should create the objects in. Not all databases have catalogs; subclasses of GenericDDLGenerator which target catalogless platforms should set this value to null as well as override getCatalogTerm() to return null.


targetSchema

protected java.lang.String targetSchema
The name of the schema in the target database that the generated DDL statements should create the objects in. Not all databases have schemas; subclasses of GenericDDLGenerator which target schemaless platforms should set this value to null as well as override getSchemaTerm() to return null.


profileFunctionMap

protected java.util.Map<java.lang.String,ProfileFunctionDescriptor> profileFunctionMap
A mapping from JDBC type code (Integer values) to appliable profile functions (min,max,avg,sum,etc...)

Constructor Detail

GenericDDLGenerator

public GenericDDLGenerator()
                    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

isReservedWord

public boolean isReservedWord(java.lang.String word)
Check to see if the word word is on the list of reserved words for this database

Specified by:
isReservedWord in interface DDLGenerator
Returns:

generateDDLScript

public java.lang.String generateDDLScript(java.util.Collection<SQLTable> tables)
                                   throws java.sql.SQLException,
                                          ArchitectException
Description copied from interface: DDLGenerator
Generates the series of DDL Statements as in DDLGenerator.generateDDLStatements(Collection), then compiles them into a formatted script complete with statement terminators and transaction start and end statements (if supported by the target platform). This script is appropriate to feed into a target database using a vendor-supplied tool for executing SQL scripts.

Specified by:
generateDDLScript in interface DDLGenerator
Parameters:
tables - The collection of tables the generated script should create.
Returns:
The String representation of the generated DDL script.
Throws:
java.sql.SQLException - If there is a problem getting type info from the target DB.
ArchitectException - If there are problems with the Architect objects.

generateDDLStatements

public final java.util.List<DDLStatement> generateDDLStatements(java.util.Collection<SQLTable> tables)
                                                         throws java.sql.SQLException,
                                                                ArchitectException
Creates a series of SQL DDL statements which will create the given list of tables in a target database. The script will include commands for defining the tables, their primary keys, other indices, and the foreign key relationships between them.

Specified by:
generateDDLStatements in interface DDLGenerator
Parameters:
tables - the tables the generated script should create.
Returns:
the list of DDL statements in the order they should be executed
Throws:
java.sql.SQLException - If there is a problem getting type info from the target DB.
ArchitectException - If there are problems with the Architect objects.
See Also:
DDLGenerator.generateDDLStatements(Collection)

endStatement

public final void endStatement(DDLStatement.StatementType type,
                               SQLObject sqlObject)
Stores all the ddl since the last call to endStatement as a SQL statement. You have to call this at the end of each statement.

Parameters:
type - the type of statement
sqlObject - the object to which the statement pertains

writeHeader

public void writeHeader()

getStatementTerminator

public java.lang.String getStatementTerminator()
Prints a single semicolon character (no newline). If your database needs something else, override this method.

Specified by:
getStatementTerminator in interface DDLGenerator

writeDDLTransactionBegin

public void writeDDLTransactionBegin()
Does nothing. If your target system supports transactional DDL, override this method and print the appropriate statement.


writeDDLTransactionEnd

public void writeDDLTransactionEnd()
Does nothing. If your target system supports transactional DDL, override this method and print the appropriate statement.


writeCreateDB

public void writeCreateDB(SQLDatabase db)

dropRelationship

public void dropRelationship(SQLRelationship r)
Description copied from interface: DDLGenerator
Appends the DDL statement for dropping the given FK relationship in this DDL Generator's target schema/catalog.

Specified by:
dropRelationship in interface DDLGenerator

addRelationship

public void addRelationship(SQLRelationship r)
Adds a statement for creating the given foreign key relationship in the target database. Depends on the getDeferrabilityClause(SQLRelationship) method for the target database's way of describing the deferrability policy.

Specified by:
addRelationship in interface DDLGenerator

supportsDeleteAction

public boolean supportsDeleteAction(SQLRelationship r)
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.


getDeleteActionClause

public java.lang.String getDeleteActionClause(SQLRelationship r)
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.

Parameters:
r - The relationship whose delete action clause to generate
Returns:
The delete action clause

supportsUpdateAction

public boolean supportsUpdateAction(SQLRelationship r)
Returns true if this DDL generator supports the given relationship's update action. The generic DDL generator claims to support all update actions, so specific platforms that don't support all update actions should override this method.


getUpdateActionClause

public java.lang.String getUpdateActionClause(SQLRelationship r)
Returns the ON UPDATE 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.

Parameters:
r - The relationship whose update action clause to generate
Returns:
The update action clause

getDeferrabilityClause

public java.lang.String getDeferrabilityClause(SQLRelationship r)
Returns the correct syntax for setting the deferrability of a foreign key relationship on this DDL Generator's target platform. Throws an UnsupportedOperationException if the platform does not support the given relationship's deferrability policy.

Parameters:
r - The relationship the deferrability clause is for
Returns:
The SQL clause for declaring the deferrability policy in r.

supportsDeferrabilityPolicy

public boolean supportsDeferrabilityPolicy(SQLRelationship r)
Returns true if the platform supports the deferrability policy of the given relationship, false otherwise. This generic method assumes support for all deferrability policies.

Returns:
Whether the chosen platform supports the deferrability.

addColumn

public void addColumn(SQLColumn c)
Description copied from interface: DDLGenerator
Appends the DDL statement for adding the given column to its parent table in this DDL Generator's target schema/catalog.

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

dropColumn

public void dropColumn(SQLColumn c)
Description copied from interface: DDLGenerator
Appends the DDL statement for dropping the given column from its parent table in this DDL Generator's target schema/catalog.

Specified by:
dropColumn in interface DDLGenerator
Parameters:
c - The column to create a DROP statement for.

modifyColumn

public void modifyColumn(SQLColumn c)
Description copied from interface: DDLGenerator
Appends the DDL statement for modifying the given column's datatype and nullability in its parent table in this DDL Generator's target schema/catalog.

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

dropTable

public void dropTable(SQLTable t)
Description copied from interface: DDLGenerator
Appends the DDL statements for dropping the table in this DDL Generator's current catalog and schema using SQLTable t's physical name.

Specified by:
dropTable in interface DDLGenerator

columnDefinition

protected java.lang.String columnDefinition(SQLColumn c,
                                            java.util.Map colNameMap)
Creates a SQL DDL snippet which consists of the column name, data type, default value, and nullability clauses.

Parameters:
c - The column to generate the DDL snippet for.
colNameMap - Dirty hack for coming up with unique physical names. The final physical name generated in the SQL snippet will be stored in this map. If you don't care about producing unique column names, just pass in a freshly-created map. See createPhysicalName(Map, SQLObject) for more information.
Returns:
The SQL snippet that describes the given column. The returned string is not delimited at the beginning or end: you're responsible for properly putting it in the context of a valid SQL statement.

columnNullability

protected java.lang.String columnNullability(SQLColumn c)

columnType

public java.lang.String columnType(SQLColumn c)
Columnn type

Specified by:
columnType in interface DDLGenerator
Returns:

getColumnDataTypeName

public java.lang.String getColumnDataTypeName(SQLColumn c)
Columnn type


failsafeGetTypeDescriptor

protected GenericTypeDescriptor failsafeGetTypeDescriptor(SQLColumn c)
Returns the type descriptor for the given column's type if that exists in this generator's typemap, else returns the default type.


addTable

public void addTable(SQLTable t)
              throws java.sql.SQLException,
                     ArchitectException
Description copied from interface: DDLGenerator
Appends the DDL statements for creating a table in this DDL Generator's current catalog and schema using SQLTable t as a template.

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

getDefaultType

protected java.lang.Object getDefaultType()
Returns the default data type for this platform. Normally, this can be VARCHAR, but if your platform doesn't have a varchar, override this method.


addPrimaryKeysToCreateTable

protected void addPrimaryKeysToCreateTable(SQLTable t)
                                    throws ArchitectException
Throws:
ArchitectException

writePrimaryKey

protected void writePrimaryKey(SQLTable t)
                        throws ArchitectException
Throws:
ArchitectException

writeExportedRelationships

protected void writeExportedRelationships(SQLTable t)
                                   throws ArchitectException
Adds statements for creating every exported key in the given table.

Throws:
ArchitectException

createTypeMap

protected void createTypeMap()
                      throws java.sql.SQLException
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.

Throws:
java.sql.SQLException

println

protected void println(java.lang.String text)

print

protected void print(java.lang.String text)

toIdentifier

public java.lang.String toIdentifier(java.lang.String name)
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

toQualifiedName

public java.lang.String toQualifiedName(SQLTable t)
Creates a fully-qualified table name from the given table's phyiscal name and this DDL Generator's current target schema and catalog.

Parameters:
t - The table whose name to qualify. The parents of this table are disregarded; only the DDL Generator's target schema and catalog matter.
Returns:
A string of the form [catalog.][schema.]table (catalog and schema are omitted if null).

toQualifiedName

public java.lang.String toQualifiedName(SQLIndex i)
Creates a qualified name from the physical name of the SQLIndex


toQualifiedName

public java.lang.String toQualifiedName(java.lang.String tname)
Creates a fully-qualified table name from the given string (which is the non-qualified table name) and this DDL Generator's current target schema and catalog.

Parameters:
tname - The table name to qualify. Must not contain the name separator character (usually '.').
Returns:
A string of the form [catalog.][schema.]table (catalog and schema are omitted if null).

getAllowConnection

public boolean getAllowConnection()
Gets the value of allowConnection

Specified by:
getAllowConnection in interface DDLGenerator
Returns:
the value of allowConnection

setAllowConnection

public void setAllowConnection(boolean argAllowConnection)
Sets the value of allowConnection

Specified by:
setAllowConnection in interface DDLGenerator
Parameters:
argAllowConnection - Value to assign to this.allowConnection

getTypeMap

public java.util.Map getTypeMap()
Gets the value of typeMap

Specified by:
getTypeMap in interface DDLGenerator
Returns:
the value of typeMap

setTypeMap

public void setTypeMap(java.util.Map argTypeMap)
Sets the value of typeMap

Specified by:
setTypeMap in interface DDLGenerator
Parameters:
argTypeMap - Value to assign to this.typeMap

getProfileFunctionMap

public java.util.Map<java.lang.String,ProfileFunctionDescriptor> getProfileFunctionMap()

setProfileFunctionMap

public void setProfileFunctionMap(java.util.Map profileFunctionMap)

getCon

public java.sql.Connection getCon()
Gets the value of con

Returns:
the value of con

setCon

public void setCon(java.sql.Connection argCon)
Sets the value of con

Parameters:
argCon - Value to assign to this.con

getWarnings

public java.util.List getWarnings()
Returns warnings.

Specified by:
getWarnings in interface DDLGenerator

getTargetCatalog

public java.lang.String getTargetCatalog()
See targetCatalog.

Specified by:
getTargetCatalog in interface DDLGenerator
Returns:
the value of targetCatalog

setTargetCatalog

public void setTargetCatalog(java.lang.String argTargetCatalog)
See targetCatalog.

Specified by:
setTargetCatalog in interface DDLGenerator
Parameters:
argTargetCatalog - Value to assign to this.targetCatalog

getTargetSchema

public java.lang.String getTargetSchema()
See targetSchema.

Specified by:
getTargetSchema in interface DDLGenerator
Returns:
the value of targetSchema

setTargetSchema

public void setTargetSchema(java.lang.String argTargetSchema)
See targetSchema.

Specified by:
setTargetSchema in interface DDLGenerator
Parameters:
argTargetSchema - Value to assign to this.targetSchema

getCatalogTerm

public java.lang.String getCatalogTerm()
The name that the target database gives to the JDBC idea of "catalog." For Oracle, this would be null (no catalogs) and for SQL Server it would be "Database".

Specified by:
getCatalogTerm in interface DDLGenerator

getSchemaTerm

public java.lang.String getSchemaTerm()
The name that the target database gives to the JDBC idea of "schema." For Oracle, this would be "Schema" and for SQL Server it would be "Owner".

Specified by:
getSchemaTerm in interface DDLGenerator

createPhysicalName

protected java.lang.String createPhysicalName(java.util.Map<java.lang.String,SQLObject> dupCheck,
                                              SQLObject so)
Generate, set, and return a valid identifier for this SQLObject.

Throws:
ArchitectException

createSeqPhysicalName

protected java.lang.String createSeqPhysicalName(java.util.Map<java.lang.String,SQLObject> dupCheck,
                                                 SQLSequence seq,
                                                 SQLColumn col)
Generate, set, and return a valid identifier for this SQLSequence. Has a side effect of changing the given SQLColumn's autoIncrementSequenceName.

Parameters:
dupCheck - The Map to check for duplicate names
seq - The SQLSequence to generate, set and return a valid identifier for.
col - The SQLColumn to where the side effect should occur.
Throws:
ArchitectException

makeDropTableSQL

public java.lang.String makeDropTableSQL(java.lang.String table)
Generates a standard DROP TABLE $tablename command. Should work on most platforms.

Specified by:
makeDropTableSQL in interface DDLGenerator
Parameters:
table - The name of the table to be dropped.
Returns:
A SQL statement which will drop the table.

makeDropForeignKeySQL

public java.lang.String makeDropForeignKeySQL(java.lang.String fkTable,
                                              java.lang.String fkName)
Generates a command for dropping a foreign key which works on some platforms. The statement looks like ALTER TABLE $fktable DROP FOREIGN KEY $fkname.

Specified by:
makeDropForeignKeySQL in interface DDLGenerator
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.

getDdlStatements

public java.util.List<DDLStatement> getDdlStatements()
Description copied from interface: DDLGenerator
Returns the list of DDL statements that have been created so far. Call DDLGenerator.generateDDLStatements(Collection) to populate this list.

Specified by:
getDdlStatements in interface DDLGenerator

dropPrimaryKey

public void dropPrimaryKey(SQLTable t)
Specified by:
dropPrimaryKey in interface DDLGenerator

addPrimaryKey

public void addPrimaryKey(SQLTable t)
                   throws ArchitectException
Specified by:
addPrimaryKey in interface DDLGenerator
Throws:
ArchitectException

addIndex

public void addIndex(SQLIndex index)
              throws ArchitectException
Adds a DDL statement to this generator that will create the given index.

Specified by:
addIndex in interface DDLGenerator
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

supportsRollback

public boolean supportsRollback()
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


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