Package com.im.commons.db.ddl
Interface DBTableInfo
-
- All Superinterfaces:
java.io.Serializable
- All Known Implementing Classes:
DBTableInfoImpl,DBTableInfoProxy
public interface DBTableInfo extends java.io.SerializableDatabase info class for a database table. The term table is used in a generic sense meaning any database artifact that can behave in a tabular fashion, and includes views (and in future synonyms, materialised views etc.). All of these will have some things like a name, columns but the different sub-types will differ in some respects e.g. views have SQL that define the view whereas plain tables so not. The properties of this class are a superset of all the properties and not all will be used for any particular sub-type. Note: this class may be refactored in future be better distinguish the different sub-types.- Author:
- Tim Dudgeon
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classDBTableInfo.TypeThe types ofDBTableInfos.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DBTableInfocopy()Creates a duplicate copy of thisDBTableInfoinstance.DBConstraintInfofindUniqueConstraintNameForColumns(java.lang.String[] columns)Retrieves constraint name for the named columns.DBColInfogetColumn(java.lang.String name)Finds aDBColInfoby its name.java.util.List<DBColInfo>getColumns()Gets the columns in thisDBTableInfo.java.util.List<DBForeignKeyInfo>getExportedFKInfo()Get the foreign keys that involve this table but are defined in a foreign key constraint definition that is defined in another table (though possibly this table).java.util.List<DBForeignKeyInfo>getImportedFKInfo()Get the foreign keys that this table defines.java.util.List<DBIndexInfo>getIndexInfo()java.lang.StringgetName()Gets the name of the database artefact represented by thisDBTableInfo.java.util.List<java.lang.String>getPrimaryKeyColumns()Gets the name of the primary key columns.java.lang.StringgetSchema()Gets the database schema name of the associated artefact.java.lang.StringgetSQL()Gets the SQL select statement if this is aDBTableInfo.Type.VIEW.java.util.List<DBTriggerInfo>getTriggerInfo()DBTableInfo.TypegetType()Gets the type of thisDBTableInfoinstance.java.util.List<DBConstraintInfo>getUniqueConstraints()booleanisReadOnly()Determines whether this database artifact allows modifications.java.lang.StringschemaPlusTable()Gets the fully qualified name of the underlying database artifact.DBTableInfoupdateColumns(java.util.List<DBColInfo> cols)DBTableInfoupdateExportedForeignKeys(java.util.List<DBForeignKeyInfo> fkKeys)DBTableInfoupdateImportedForeignKeys(java.util.List<DBForeignKeyInfo> pkKeys)DBTableInfoupdateIndexInfos(java.util.List<DBIndexInfo> indexes)DBTableInfoupdateUniqueConstraintInfos(java.util.List<DBConstraintInfo> constraints)
-
-
-
Method Detail
-
getType
DBTableInfo.Type getType()
Gets the type of thisDBTableInfoinstance.- Returns:
- This
DBTableInfo's type.
-
getName
java.lang.String getName()
Gets the name of the database artefact represented by thisDBTableInfo.- Returns:
- The database artifact's name.
-
getSchema
java.lang.String getSchema()
Gets the database schema name of the associated artefact.- Returns:
- The database artifact's schema name. This can return
nullif the database does not use the concept of schemas.
-
schemaPlusTable
java.lang.String schemaPlusTable()
Gets the fully qualified name of the underlying database artifact.- Returns:
- The concatenated form of
getName()andgetSchema().
-
getSQL
java.lang.String getSQL()
Gets the SQL select statement if this is aDBTableInfo.Type.VIEW.- Returns:
- The SQL select string or
null.
-
isReadOnly
boolean isReadOnly()
Determines whether this database artifact allows modifications.- Returns:
trueif this database artifact is readonly and cannot be modified.
-
copy
DBTableInfo copy()
Creates a duplicate copy of thisDBTableInfoinstance.- Returns:
- A new
DBTableInfoinstance.
-
findUniqueConstraintNameForColumns
DBConstraintInfo findUniqueConstraintNameForColumns(java.lang.String[] columns)
Retrieves constraint name for the named columns. The method will return name of the unique constraint for the given set of columns. The constraint name may beDatabasePlatform.NAME_PRIMARY_KEY_CONSTRAINT, which may be handled differently in some databases - for drop, useDatabasePlatform.sqlDropPrimaryConstraint(String, String, String[]).- Parameters:
columns- DB columns- Returns:
- The constraint, or
nullif there's no unique constraint.
-
getColumn
DBColInfo getColumn(java.lang.String name)
Finds aDBColInfoby its name. This will search through the columns in thisDBTableInfofor a column with the required name.- Parameters:
name- The name of the column to find.- Returns:
- The
DBColInfowith the required name ornullif no such column exists.
-
getColumns
java.util.List<DBColInfo> getColumns()
Gets the columns in thisDBTableInfo.- Returns:
- The list of columns.
-
getExportedFKInfo
java.util.List<DBForeignKeyInfo> getExportedFKInfo()
Get the foreign keys that involve this table but are defined in a foreign key constraint definition that is defined in another table (though possibly this table). e.g. the keys in this table that are referred to in a foreign key constraint definition somewhere.- Returns:
- A list of foreign keys
-
getImportedFKInfo
java.util.List<DBForeignKeyInfo> getImportedFKInfo()
Get the foreign keys that this table defines. e.g. the primary keys of other tables (or possibly this table) that are referred to in a foreign key constraint definition.- Returns:
- A list of foreign keys
-
getIndexInfo
java.util.List<DBIndexInfo> getIndexInfo()
-
getPrimaryKeyColumns
java.util.List<java.lang.String> getPrimaryKeyColumns()
Gets the name of the primary key columns.- Returns:
- The primary key column names. It can return an empty list, but not
null.
-
getTriggerInfo
java.util.List<DBTriggerInfo> getTriggerInfo()
-
getUniqueConstraints
java.util.List<DBConstraintInfo> getUniqueConstraints()
-
updateColumns
DBTableInfo updateColumns(java.util.List<DBColInfo> cols)
-
updateImportedForeignKeys
DBTableInfo updateImportedForeignKeys(java.util.List<DBForeignKeyInfo> pkKeys)
-
updateExportedForeignKeys
DBTableInfo updateExportedForeignKeys(java.util.List<DBForeignKeyInfo> fkKeys)
-
updateIndexInfos
DBTableInfo updateIndexInfos(java.util.List<DBIndexInfo> indexes)
-
updateUniqueConstraintInfos
DBTableInfo updateUniqueConstraintInfos(java.util.List<DBConstraintInfo> constraints)
-
-