public class Table extends Object implements Comparable<Table>
Table is one of the basic building blocks of SchemaSpy
that knows everything about the database table's metadata.| 修飾子とタイプ | フィールドと説明 |
|---|---|
protected CaseInsensitiveMap<TableColumn> |
columns |
protected Database |
db |
protected Properties |
properties |
| コンストラクタと説明 |
|---|
Table(Database db,
String schema,
String name,
String comments,
Properties properties,
Pattern excludeIndirectColumns,
Pattern excludeColumns)
Construct a table that knows everything about the database table's metadata
|
| 修飾子とタイプ | メソッドと説明 |
|---|---|
void |
addCheckConstraint(String constraintName,
String text)
Add a check constraint to the table
(no real details, just name and textual representation)
|
protected void |
addColumn(ResultSet rs,
Pattern excludeIndirectColumns,
Pattern excludeColumns) |
protected TableColumn |
addColumn(TableColumnMeta colMeta)
Add a column that's defined in xml metadata.
|
void |
addedChild()
Notification that's called to indicate that a child has been added to
this table
|
void |
addedParent()
Notification that's called to indicate that a parent has been added to
this table
|
protected void |
addForeignKey(String fkName,
String fkColName,
String pkTableSchema,
String pkTableName,
String pkColName,
int updateRule,
int deleteRule,
Map<String,Table> tables,
Pattern excludeIndirectColumns,
Pattern excludeColumns) |
int |
compareTo(Table other)
Compare this table to another table.
|
void |
connect(TableMeta tableMeta,
Map<String,Table> tables,
Map<String,Table> remoteTables)
Same as
#connectForeignKeys(Map, Database, Properties, Pattern, Pattern),
but uses XML-based metadata |
void |
connectForeignKeys(Map<String,Table> tables,
Pattern excludeIndirectColumns,
Pattern excludeColumns)
"Connect" all of this table's foreign keys to their referenced primary keys
(and, in some cases, do the reverse as well).
|
protected int |
fetchNumRows()
Fetch the number of rows contained in this table.
|
protected int |
fetchNumRows(String clause,
boolean forceQuotes) |
Map<String,String> |
getCheckConstraints()
Returns the check constraints associated with this table
|
TableColumn |
getColumn(String columnName)
Returns the
TableColumn with the given name, or null
if it doesn't exist |
List<TableColumn> |
getColumns()
Returns
List of TableColumns in ascending column number order. |
String |
getComments() |
Collection<ForeignKeyConstraint> |
getForeignKeys()
Get the foreign keys associated with this table
|
Object |
getId() |
TableIndex |
getIndex(String indexName) |
Set<TableIndex> |
getIndexes()
Returns the indexes that are applied to this table
|
int |
getMaxChildren()
Returns the maximum number of children that this table has had before
any had been removed during dependency analysis
|
int |
getMaxParents()
Returns the maximum number of parents that this table has had before
any had been removed during dependency analysis
|
String |
getName()
Returns the name of the table
|
int |
getNumChildren()
Returns the number of tables that reference this table
|
int |
getNumNonImpliedChildren()
Returns the number of non-implied children
|
int |
getNumNonImpliedParents()
Returns the number of non-implied parents
|
int |
getNumParents()
Returns the number of tables that are referenced by this table
|
int |
getNumRows()
Returns the number of rows contained in this table, or -1 if unable to determine
the number of rows.
|
List<TableColumn> |
getPrimaryColumns()
Returns a collection of table columns that have been identified as "primary"
|
String |
getSchema()
Returns the schema that the table belongs to
|
String |
getViewSql()
If this is a view it returns the SQL used to create the view (if it's available).
|
boolean |
isLeaf()
Returns
true if this table is referenced by no other tables. |
boolean |
isOrphan(boolean withImpliedRelationships)
Returns
true if this table has no relationships |
boolean |
isRemote()
Returns
true if this table is remote (in another schema), false otherwise |
boolean |
isRoot()
Returns
true if this table references no other tables.. |
boolean |
isView()
Returns
true if this is a view, false otherwise |
ForeignKeyConstraint |
removeAForeignKeyConstraint()
Remove one foreign key constraint.
|
List<ForeignKeyConstraint> |
removeNonRealForeignKeys()
Remove any non-real foreign keys
|
ForeignKeyConstraint |
removeSelfReferencingConstraint()
Remove a single self referencing constraint if one exists.
|
void |
setComments(String comments)
Sets the comments that are associated with this table
|
void |
setId(Object id)
Object IDs are useful for tables such as DB/2 that many times
give error messages based on object ID and not name
|
void |
setNumRows(int numRows)
Explicitly set the number of rows in this table
|
String |
toString() |
void |
unlinkChildren()
"Unlink" all of the child tables from this table
|
void |
unlinkParents()
"Unlink" all of the parent tables from this table
|
void |
update(TableMeta tableMeta)
Update the table with the specified XML-derived metadata
|
protected final CaseInsensitiveMap<TableColumn> columns
protected final Database db
protected final Properties properties
public Table(Database db, String schema, String name, String comments, Properties properties, Pattern excludeIndirectColumns, Pattern excludeColumns) throws SQLException
db - schema - name - comments - properties - excludeIndirectColumns - excludeColumns - SQLExceptionpublic void connectForeignKeys(Map<String,Table> tables, Pattern excludeIndirectColumns, Pattern excludeColumns) throws SQLException
tables - excludeIndirectColumns - excludeColumns - SQLExceptionpublic Collection<ForeignKeyConstraint> getForeignKeys()
public void addCheckConstraint(String constraintName, String text)
constraintName - text - protected void addForeignKey(String fkName, String fkColName, String pkTableSchema, String pkTableName, String pkColName, int updateRule, int deleteRule, Map<String,Table> tables, Pattern excludeIndirectColumns, Pattern excludeColumns) throws SQLException
rs - ResultSet from DatabaseMetaData.getImportedKeys(String, String, String)
rs.getString("FK_NAME");
rs.getString("FKCOLUMN_NAME");
rs.getString("PKTABLE_SCHEM");
rs.getString("PKTABLE_NAME");
rs.getString("PKCOLUMN_NAME");tables - Mapdb - SQLExceptionprotected void addColumn(ResultSet rs, Pattern excludeIndirectColumns, Pattern excludeColumns) throws SQLException
rs - - from DatabaseMetaData.getColumns(String, String, String, String)excludeIndirectColumns - excludeColumns - SQLExceptionprotected TableColumn addColumn(TableColumnMeta colMeta)
columns.colMeta - public TableIndex getIndex(String indexName)
indexName - public String getSchema()
public String getName()
public void setId(Object id)
id - public Object getId()
setId(Object)public Map<String,String> getCheckConstraints()
public Set<TableIndex> getIndexes()
public List<TableColumn> getPrimaryColumns()
public String getComments()
null if none.public void setComments(String comments)
comments - public TableColumn getColumn(String columnName)
TableColumn with the given name, or null
if it doesn't existcolumnName - public List<TableColumn> getColumns()
List of TableColumns in ascending column number order.public boolean isRoot()
true if this table references no other tables..
Used in dependency analysis.public boolean isLeaf()
true if this table is referenced by no other tables.
Used in dependency analysis.public int getMaxParents()
public void addedParent()
public void unlinkParents()
public int getMaxChildren()
public void addedChild()
public void unlinkChildren()
public ForeignKeyConstraint removeSelfReferencingConstraint()
public List<ForeignKeyConstraint> removeNonRealForeignKeys()
public int getNumChildren()
public int getNumNonImpliedChildren()
public int getNumParents()
public int getNumNonImpliedParents()
public ForeignKeyConstraint removeAForeignKeyConstraint()
public boolean isView()
true if this is a view, false otherwisepublic boolean isRemote()
true if this table is remote (in another schema), false otherwisepublic String getViewSql()
null if it's not a view or the SQL isn't available.isView()public int getNumRows()
public void setNumRows(int numRows)
numRows - protected int fetchNumRows()
db - DatabaseSQLExceptionprotected int fetchNumRows(String clause, boolean forceQuotes) throws SQLException
SQLExceptionpublic void update(TableMeta tableMeta)
tableMeta - public void connect(TableMeta tableMeta, Map<String,Table> tables, Map<String,Table> remoteTables)
#connectForeignKeys(Map, Database, Properties, Pattern, Pattern),
but uses XML-based metadatatableMeta - tables - remoteTables - public boolean isOrphan(boolean withImpliedRelationships)
true if this table has no relationshipswithImpliedRelationships - booleanpublic int compareTo(Table other)
compareTo インタフェース内 Comparable<Table>Comparable#compareTo(Object)}Copyright © 2016. All Rights Reserved.