|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.h2.engine.DbObjectBase
org.h2.schema.SchemaObjectBase
org.h2.table.Table
public abstract class Table
This is the base class for most tables. A table contains a list of columns and a list of rows.
Field Summary | |
---|---|
protected Column[] |
columns
The columns of this table. |
protected CompareMode |
compareMode
The compare mode used for this table. |
protected int |
memoryPerRow
The amount of memory required for a row if all values would be very small. |
static java.lang.String |
SYSTEM_TABLE
The table type name for system tables. |
static java.lang.String |
TABLE
The table type name for regular data tables. |
static java.lang.String |
TABLE_LINK
The table type name for linked tables. |
static int |
TYPE_CACHED
The table type that means this table is a regular persistent table. |
static int |
TYPE_MEMORY
The table type that means this table is a regular persistent table. |
static java.lang.String |
VIEW
The table type name for views. |
Fields inherited from class org.h2.engine.DbObjectBase |
---|
comment, database, trace |
Fields inherited from interface org.h2.engine.DbObject |
---|
AGGREGATE, COMMENT, CONSTANT, CONSTRAINT, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, TABLE_OR_VIEW, TRIGGER, USER, USER_DATATYPE |
Method Summary | |
---|---|
void |
addConstraint(Constraint constraint)
Add a constraint to the table. |
void |
addDependencies(java.util.HashSet<DbObject> dependencies)
Add all objects that this table depends on to the hash set. |
abstract Index |
addIndex(Session session,
java.lang.String indexName,
int indexId,
IndexColumn[] cols,
IndexType indexType,
int headPos,
java.lang.String comment)
Create an index for this table |
abstract void |
addRow(Session session,
Row row)
Add a row to the table and all indexes. |
void |
addSequence(Sequence sequence)
Add a sequence to this table. |
void |
addTrigger(TriggerObject trigger)
Add a trigger to this table. |
void |
addView(TableView view)
Add a view to this table. |
abstract boolean |
canDrop()
Check if this table can be dropped. |
abstract boolean |
canGetRowCount()
Check if the row count can be retrieved quickly. |
boolean |
canTruncate()
Check if this table can be truncated. |
void |
checkColumnIsNotReferenced(Column col)
Check that this column is not referenced by a referential constraint or multi-column index. |
ObjectArray<Session> |
checkDeadlock(Session session,
Session clash,
java.util.Set<Session> visited)
Check if a deadlock occurred. |
abstract void |
checkSupportAlter()
Check if this table supports ALTER TABLE. |
abstract void |
close(Session session)
Close the table object and flush changes. |
int |
compareTypeSave(Value a,
Value b)
Compare two values with the current comparison mode. |
Index |
findPrimaryKey()
Get the primary key index if there is one, or null if there is none. |
void |
fireAfter(Session session)
Fire the after update triggers for this table. |
void |
fireAfterRow(Session session,
Row oldRow,
Row newRow)
Fire all triggers that need to be called after a row is updated. |
void |
fireBefore(Session session)
Fire the before update triggers for this table. |
void |
fireBeforeRow(Session session,
Row oldRow,
Row newRow)
Fire all triggers that need to be called before a row is updated. |
boolean |
fireRow()
Check if row based triggers or constraints are defined. |
PlanItem |
getBestPlanItem(Session session,
int[] masks)
Get the best plan for the given search mask. |
boolean |
getCheckForeignKeyConstraints()
|
ObjectArray<DbObject> |
getChildren()
Get the list of dependent children (for tables, this includes indexes and so on). |
Column |
getColumn(int index)
Get the column at the given index. |
Column |
getColumn(java.lang.String columnName)
Get the column with the given name. |
Column[] |
getColumns()
|
CompareMode |
getCompareMode()
|
ObjectArray<Constraint> |
getConstraints()
|
java.lang.String |
getCreateSQLForCopy(Table table,
java.lang.String quotedName)
Build a SQL statement to re-create the object, or to create a copy of the object with a different name or referencing a different table |
abstract ObjectArray<Index> |
getIndexes()
Get all indexes for this table. |
Index |
getIndexForColumn(Column column,
boolean first)
Get the index that has the given column as the first element. |
abstract long |
getMaxDataModificationId()
Get the last data modification id. |
boolean |
getOnCommitDrop()
|
boolean |
getOnCommitTruncate()
|
Index |
getPrimaryKey()
|
abstract long |
getRowCount(Session session)
Get the row count for this table. |
abstract long |
getRowCountApproximation()
Get the approximated row count for this table. |
abstract Index |
getScanIndex(Session session)
Get the scan index to iterate through all rows. |
abstract java.lang.String |
getTableType()
Get the table type name |
Row |
getTemplateRow()
|
SearchRow |
getTemplateSimpleRow(boolean singleColumn)
Get a new simple row object. |
int |
getType()
Get the object type. |
abstract Index |
getUniqueIndex()
Get any unique index for this table if one exists. |
abstract boolean |
isDeterministic()
Check if the table is deterministic. |
boolean |
isGlobalTemporary()
|
abstract boolean |
isLockedExclusively()
Check if this table is locked exclusively. |
boolean |
isPersistData()
|
boolean |
isPersistIndexes()
|
abstract void |
lock(Session session,
boolean exclusive,
boolean force)
Lock the table for the given session. |
void |
removeChildrenAndResources(Session session)
Remove all dependent objects and free all resources (files, blocks in files) of this object. |
void |
removeConstraint(Constraint constraint)
Remove the given constraint from the list. |
void |
removeIndex(Index index)
Remove the given index from the list. |
void |
removeIndexOrTransferOwnership(Session session,
Index index)
If the index is still required by a constraint, transfer the ownership to it. |
abstract void |
removeRow(Session session,
Row row)
Remove a row from the table and all indexes. |
void |
removeSequence(Session session,
Sequence sequence)
Remove a sequence from the table. |
void |
removeTrigger(TriggerObject trigger)
Remove the given trigger from the list. |
void |
rename(java.lang.String newName)
Rename the object. |
void |
renameColumn(Column column,
java.lang.String newName)
Rename a column of this table. |
void |
setCheckForeignKeyConstraints(Session session,
boolean enabled,
boolean checkExisting)
Enable or disable foreign key constraint checking for this table. |
protected void |
setColumns(Column[] columns)
|
void |
setOnCommitDrop(boolean onCommitDrop)
|
void |
setOnCommitTruncate(boolean onCommitTruncate)
|
abstract void |
truncate(Session session)
Remove all rows from the table and indexes. |
abstract void |
unlock(Session s)
Release the lock for this session. |
void |
updateRows(Prepared prepared,
Session session,
RowList rows)
Update a list of rows in this table. |
void |
validateConvertUpdateSequence(Session session,
Row row)
Validate all values in this row, convert the values if required, and update the sequence values if required. |
Methods inherited from class org.h2.schema.SchemaObjectBase |
---|
getSchema, getSQL, initSchemaObjectBase |
Methods inherited from class org.h2.engine.DbObjectBase |
---|
checkRename, getComment, getCreateSQL, getDatabase, getDropSQL, getHeadPos, getId, getModificationId, getName, initDbObjectBase, invalidate, isTemporary, setComment, setModified, setObjectName, setTemporary, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.h2.engine.DbObject |
---|
checkRename, getComment, getCreateSQL, getDatabase, getDropSQL, getHeadPos, getId, getModificationId, getName, isTemporary, setComment, setModified, setTemporary |
Field Detail |
---|
public static final int TYPE_CACHED
public static final int TYPE_MEMORY
public static final java.lang.String TABLE_LINK
public static final java.lang.String SYSTEM_TABLE
public static final java.lang.String TABLE
public static final java.lang.String VIEW
protected Column[] columns
protected int memoryPerRow
protected CompareMode compareMode
Method Detail |
---|
public void rename(java.lang.String newName) throws java.sql.SQLException
DbObject
rename
in interface DbObject
rename
in class DbObjectBase
newName
- the new name
java.sql.SQLException
public abstract void lock(Session session, boolean exclusive, boolean force) throws java.sql.SQLException
session
- the sessionexclusive
- true for write locks, false for read locksforce
- lock even in the MVCC mode
java.sql.SQLException
- if a lock timeout occurredpublic abstract void close(Session session) throws java.sql.SQLException
session
- the session
java.sql.SQLException
public abstract void unlock(Session s)
s
- the sessionpublic abstract Index addIndex(Session session, java.lang.String indexName, int indexId, IndexColumn[] cols, IndexType indexType, int headPos, java.lang.String comment) throws java.sql.SQLException
session
- the sessionindexName
- the name of the indexindexId
- the idcols
- the index columnsindexType
- the index typeheadPos
- the position of the head (if the index already exists)comment
- the comment
java.sql.SQLException
public abstract void removeRow(Session session, Row row) throws java.sql.SQLException
session
- the sessionrow
- the row
java.sql.SQLException
public abstract void truncate(Session session) throws java.sql.SQLException
session
- the session
java.sql.SQLException
public abstract void addRow(Session session, Row row) throws java.sql.SQLException
session
- the sessionrow
- the row
java.sql.SQLException
- if a constraint was violatedpublic abstract void checkSupportAlter() throws java.sql.SQLException
java.sql.SQLException
- if it is not supportedpublic abstract java.lang.String getTableType()
public abstract Index getScanIndex(Session session) throws java.sql.SQLException
session
- the session
java.sql.SQLException
public abstract Index getUniqueIndex()
public abstract ObjectArray<Index> getIndexes()
public abstract boolean isLockedExclusively()
public abstract long getMaxDataModificationId()
public abstract boolean isDeterministic()
public abstract boolean canGetRowCount()
public abstract boolean canDrop()
public abstract long getRowCount(Session session) throws java.sql.SQLException
session
- the session
java.sql.SQLException
public abstract long getRowCountApproximation()
public java.lang.String getCreateSQLForCopy(Table table, java.lang.String quotedName)
DbObjectBase
getCreateSQLForCopy
in interface DbObject
getCreateSQLForCopy
in class DbObjectBase
table
- the new table namequotedName
- the new quoted name
public void addDependencies(java.util.HashSet<DbObject> dependencies)
dependencies
- the current set of dependenciespublic ObjectArray<DbObject> getChildren()
DbObject
getChildren
in interface DbObject
getChildren
in class DbObjectBase
protected void setColumns(Column[] columns) throws java.sql.SQLException
java.sql.SQLException
public void renameColumn(Column column, java.lang.String newName) throws java.sql.SQLException
column
- the column to renamenewName
- the new column name
java.sql.SQLException
public void updateRows(Prepared prepared, Session session, RowList rows) throws java.sql.SQLException
prepared
- the prepared statementsession
- the sessionrows
- a list of row pairs of the form old row, new row, old row,
new row,...
java.sql.SQLException
public void removeChildrenAndResources(Session session) throws java.sql.SQLException
DbObjectBase
removeChildrenAndResources
in interface DbObject
removeChildrenAndResources
in class DbObjectBase
session
- the session
java.sql.SQLException
public void checkColumnIsNotReferenced(Column col) throws java.sql.SQLException
col
- the column
java.sql.SQLException
- if the column is referencedpublic Row getTemplateRow()
public SearchRow getTemplateSimpleRow(boolean singleColumn)
singleColumn
- if only one value need to be stored
public Column[] getColumns()
public int getType()
DbObjectBase
getType
in interface DbObject
getType
in class DbObjectBase
public Column getColumn(int index)
index
- the column index (0, 1,...)
public Column getColumn(java.lang.String columnName) throws java.sql.SQLException
columnName
- the column name
java.sql.SQLException
- if the column was not foundpublic PlanItem getBestPlanItem(Session session, int[] masks) throws java.sql.SQLException
session
- the sessionmasks
- null means 'always false'
java.sql.SQLException
public Index findPrimaryKey()
public Index getPrimaryKey() throws java.sql.SQLException
java.sql.SQLException
public void validateConvertUpdateSequence(Session session, Row row) throws java.sql.SQLException
session
- the sessionrow
- the row
java.sql.SQLException
public void removeIndex(Index index)
index
- the index to removepublic void removeConstraint(Constraint constraint)
constraint
- the constraint to removepublic void removeSequence(Session session, Sequence sequence)
session
- the sessionsequence
- the sequence to removepublic void removeTrigger(TriggerObject trigger)
trigger
- the trigger to removepublic void addView(TableView view)
view
- the view to addpublic void addConstraint(Constraint constraint)
constraint
- the constraint to addpublic ObjectArray<Constraint> getConstraints()
public void addSequence(Sequence sequence)
sequence
- the sequence to addpublic void addTrigger(TriggerObject trigger)
trigger
- the trigger to addpublic void fireBefore(Session session) throws java.sql.SQLException
session
- the session
java.sql.SQLException
public void fireAfter(Session session) throws java.sql.SQLException
session
- the session
java.sql.SQLException
public boolean fireRow()
public void fireBeforeRow(Session session, Row oldRow, Row newRow) throws java.sql.SQLException
session
- the sessionoldRow
- the old data or null for an insertnewRow
- the new data or null for a delete
java.sql.SQLException
public void fireAfterRow(Session session, Row oldRow, Row newRow) throws java.sql.SQLException
session
- the sessionoldRow
- the old data or null for an insertnewRow
- the new data or null for a delete
java.sql.SQLException
public boolean isGlobalTemporary()
public boolean canTruncate()
public void setCheckForeignKeyConstraints(Session session, boolean enabled, boolean checkExisting) throws java.sql.SQLException
session
- the sessionenabled
- true if checking should be enabledcheckExisting
- true if existing rows must be checked during this call
java.sql.SQLException
public boolean getCheckForeignKeyConstraints()
public Index getIndexForColumn(Column column, boolean first)
column
- the columnfirst
- if the min value should be returned
public boolean getOnCommitDrop()
public void setOnCommitDrop(boolean onCommitDrop)
public boolean getOnCommitTruncate()
public void setOnCommitTruncate(boolean onCommitTruncate)
public void removeIndexOrTransferOwnership(Session session, Index index) throws java.sql.SQLException
session
- the sessionindex
- the index that is no longer required
java.sql.SQLException
public ObjectArray<Session> checkDeadlock(Session session, Session clash, java.util.Set<Session> visited)
session
- the session to be tested forclash
- set with sessions already visited, and null when starting
verificationvisited
- set with sessions already visited, and null when starting
verification
public boolean isPersistIndexes()
public boolean isPersistData()
public int compareTypeSave(Value a, Value b) throws java.sql.SQLException
a
- the first valueb
- the second value
java.sql.SQLException
public CompareMode getCompareMode()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |