Package org.h2.table
Class TableLink
java.lang.Object
org.h2.engine.DbObject
org.h2.schema.SchemaObject
org.h2.table.Table
org.h2.table.TableLink
- All Implemented Interfaces:
HasSQL
A linked table contains connection information for a table accessible by
JDBC. The table may be stored in a different database.
-
Field Summary
Fields inherited from class org.h2.table.Table
columns, compareMode, EXCLUSIVE_LOCK, READ_LOCK, TYPE_CACHED, TYPE_MEMORY, WRITE_LOCKFields inherited from class org.h2.engine.DbObject
AGGREGATE, comment, COMMENT, CONSTANT, CONSTRAINT, database, DOMAIN, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, SYNONYM, TABLE_OR_VIEW, trace, TRIGGER, USERFields inherited from interface org.h2.util.HasSQL
ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddIndex(SessionLocal session, String indexName, int indexId, IndexColumn[] cols, int uniqueColumnCount, IndexType indexType, boolean create, String indexComment) Create an index for this tablevoidaddRow(SessionLocal session, Row row) Add a row to the table and all indexes.booleancanDrop()Check if this table can be dropped.booleancanGetRowCount(SessionLocal session) Check if the row count can be retrieved quickly.voidCheck if this table supports ALTER TABLE.voidLinked tables don't know if they are readonly.voidclose(SessionLocal session) Close the table object and flush changes.voidconvertInsertRow(SessionLocal session, Row row, Boolean overridingSystem) Prepares the specified row for INSERT operation.voidconvertUpdateRow(SessionLocal session, Row row, boolean fromTrigger) Prepares the specified row for UPDATE operation.execute(String sql, ArrayList<Value> params, boolean reusePrepared, SessionLocal session) Execute a SQL statement using the given parameters.booleanThe autocommit modeConstruct the CREATE ...Construct a DROP ...intThe number of rows to fetch default is 0Returns the identifier quote string or space.Get all indexes for this table.longGet the last data modification id.longgetRowCount(SessionLocal session) Get the row count for this table.longgetRowCountApproximation(SessionLocal session) Get the approximated row count for this table.getScanIndex(SessionLocal session) Get the scan index to iterate through all rows.Get the table type namebooleanCheck if the table is deterministic.booleanReturns whether this table is insertable.booleanisOracle()voidremoveChildrenAndResources(SessionLocal session) Delete all dependent children objects and resources of this object.voidremoveRow(SessionLocal session, Row row) Remove a row from the table and all indexes.voidreusePreparedStatement(PreparedStatement prep, String sql) Add this prepared statement to the list of cached statements.voidsetAutoCommit(boolean mode) Specify if the autocommit mode is activated or notvoidsetFetchSize(int fetchSize) Specify the number of rows fetched by the linked table commandvoidsetGlobalTemporary(boolean globalTemporary) voidsetReadOnly(boolean readOnly) longtruncate(SessionLocal session) Remove all rows from the table and indexes.voidupdateRows(Prepared prepared, SessionLocal session, LocalResult rows) Update a list of rows in this table.static DbExceptionwrapException(String sql, Exception ex) Wrap a SQL exception that occurred while accessing a linked table.Methods inherited from class org.h2.table.Table
addConstraint, addDependencies, addDependentMaterializedView, addDependentView, addSequence, addSynonym, addTrigger, canReference, canTruncate, checkDeadlock, compareValues, createRow, doesColumnExist, dropMultipleColumnsConstraintsAndIndexes, findColumn, findPrimaryKey, fire, fireAfterRow, fireBeforeRow, fireRow, getBestPlanItem, getCheckForeignKeyConstraints, getChildren, getColumn, getColumn, getColumn, getColumns, getCompareMode, getConstraints, getDependentMaterializedViews, getDependentViews, getDiskSpaceUsed, getIdentityColumn, getIndex, getIndexForColumn, getMainIndexColumn, getNullRow, getOnCommitDrop, getOnCommitTruncate, getPrimaryKey, getRow, getRowFactory, getRowIdColumn, getScanIndex, getSQLTableType, getTemplateRow, getTemplateSimpleRow, getTriggers, getType, getVisibleColumns, hasSelectTrigger, isGlobalTemporary, isLockedExclusively, isLockedExclusivelyBy, isPersistData, isPersistIndexes, isQueryComparable, isRowLockable, isView, lock, lockRow, removeColumnExpressionsDependencies, removeConstraint, removeDependentMaterializedView, removeDependentView, removeIndex, removeIndexOrTransferOwnership, removeSequence, removeSynonym, removeTrigger, rename, renameColumn, setCheckForeignKeyConstraints, setColumns, setOnCommitDrop, setOnCommitTruncate, unlock, updateRowMethods inherited from class org.h2.schema.SchemaObject
getSchema, getSQL, getSQLMethods inherited from class org.h2.engine.DbObject
checkRename, getComment, getCreateSQLForCopy, getCreateSQLForMeta, getDatabase, getId, getModificationId, getName, invalidate, isTemporary, isValid, setComment, setModified, setObjectName, setTemporary, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.h2.util.HasSQL
getTraceSQL
-
Constructor Details
-
TableLink
-
-
Method Details
-
getDropSQL
Description copied from class:DbObjectConstruct a DROP ... SQL statement for this object.- Overrides:
getDropSQLin classDbObject- Returns:
- the SQL statement
-
getCreateSQL
Description copied from class:DbObjectConstruct the CREATE ... SQL statement for this object.- Specified by:
getCreateSQLin classDbObject- Returns:
- the SQL statement
-
addIndex
public Index addIndex(SessionLocal session, String indexName, int indexId, IndexColumn[] cols, int uniqueColumnCount, IndexType indexType, boolean create, String indexComment) Description copied from class:TableCreate an index for this table- Specified by:
addIndexin classTable- Parameters:
session- the sessionindexName- the name of the indexindexId- the idcols- the index columnsuniqueColumnCount- the count of unique columnsindexType- the index typecreate- whether this is a new indexindexComment- the comment- Returns:
- the index
-
getScanIndex
Description copied from class:TableGet the scan index to iterate through all rows.- Specified by:
getScanIndexin classTable- Parameters:
session- the session- Returns:
- the index
-
isInsertable
public boolean isInsertable()Description copied from class:TableReturns whether this table is insertable.- Overrides:
isInsertablein classTable- Returns:
- whether this table is insertable
-
removeRow
Description copied from class:TableRemove a row from the table and all indexes. -
addRow
Description copied from class:TableAdd a row to the table and all indexes. -
close
Description copied from class:TableClose the table object and flush changes. -
getRowCount
Description copied from class:TableGet the row count for this table.- Specified by:
getRowCountin classTable- Parameters:
session- the session- Returns:
- the row count
-
wrapException
Wrap a SQL exception that occurred while accessing a linked table.- Parameters:
sql- the SQL statementex- the exception from the remote database- Returns:
- the wrapped exception
-
getQualifiedTable
-
execute
public PreparedStatement execute(String sql, ArrayList<Value> params, boolean reusePrepared, SessionLocal session) Execute a SQL statement using the given parameters. Prepared statements are kept in a hash map to avoid re-creating them.- Parameters:
sql- the SQL statementparams- the parameters or nullreusePrepared- if the prepared statement can be re-used immediatelysession- the session- Returns:
- the prepared statement, or null if it is re-used
-
checkSupportAlter
public void checkSupportAlter()Description copied from class:TableCheck if this table supports ALTER TABLE.- Specified by:
checkSupportAlterin classTable
-
truncate
Description copied from class:TableRemove all rows from the table and indexes. -
canGetRowCount
Description copied from class:TableCheck if the row count can be retrieved quickly.- Specified by:
canGetRowCountin classTable- Parameters:
session- the session- Returns:
- true if it can
-
canDrop
public boolean canDrop()Description copied from class:TableCheck if this table can be dropped. -
getTableType
Description copied from class:TableGet the table type name- Specified by:
getTableTypein classTable- Returns:
- the table type name
-
removeChildrenAndResources
Description copied from class:DbObjectDelete all dependent children objects and resources of this object.- Overrides:
removeChildrenAndResourcesin classTable- Parameters:
session- the session
-
isOracle
public boolean isOracle() -
getIndexes
Description copied from class:TableGet all indexes for this table.- Specified by:
getIndexesin classTable- Returns:
- the list of indexes
-
getMaxDataModificationId
public long getMaxDataModificationId()Description copied from class:TableGet the last data modification id.- Specified by:
getMaxDataModificationIdin classTable- Returns:
- the modification id
-
updateRows
Description copied from class:TableUpdate a list of rows in this table.- Overrides:
updateRowsin classTable- Parameters:
prepared- the prepared statementsession- the sessionrows- a list of row pairs of the form old row, new row, old row, new row,...
-
setGlobalTemporary
public void setGlobalTemporary(boolean globalTemporary) -
setReadOnly
public void setReadOnly(boolean readOnly) -
getRowCountApproximation
Description copied from class:TableGet the approximated row count for this table.- Specified by:
getRowCountApproximationin classTable- Parameters:
session- the session- Returns:
- the approximated row count
-
reusePreparedStatement
Add this prepared statement to the list of cached statements.- Parameters:
prep- the prepared statementsql- the SQL statement
-
isDeterministic
public boolean isDeterministic()Description copied from class:TableCheck if the table is deterministic.- Specified by:
isDeterministicin classTable- Returns:
- true if it is
-
checkWritingAllowed
public void checkWritingAllowed()Linked tables don't know if they are readonly. This overwrites the default handling.- Overrides:
checkWritingAllowedin classTable
-
convertInsertRow
Description copied from class:TablePrepares the specified row for INSERT operation. Identity, default, and generated values are evaluated, all values are converted to target data types and validated. Base value of identity column is updated when required by compatibility mode.- Overrides:
convertInsertRowin classTable- Parameters:
session- the sessionrow- the rowoverridingSystem-Boolean.TRUEforOVERRIDING SYSTEM VALUES,Boolean.FALSEforOVERRIDING USER VALUES,nullif override clause is not specified
-
convertUpdateRow
Description copied from class:TablePrepares the specified row for UPDATE operation. Default and generated values are evaluated, all values are converted to target data types and validated. Base value of identity column is updated when required by compatibility mode.- Overrides:
convertUpdateRowin classTable- Parameters:
session- the sessionrow- the rowfromTrigger-trueif row was modified by INSERT or UPDATE trigger
-
setFetchSize
public void setFetchSize(int fetchSize) Specify the number of rows fetched by the linked table command- Parameters:
fetchSize- to set
-
setAutoCommit
public void setAutoCommit(boolean mode) Specify if the autocommit mode is activated or not- Parameters:
mode- to set
-
getAutocommit
public boolean getAutocommit()The autocommit mode- Returns:
- true if autocommit is on
-
getFetchSize
public int getFetchSize()The number of rows to fetch default is 0- Returns:
- number of rows to fetch
-
getIdentifierQuoteString
Returns the identifier quote string or space.- Returns:
- the identifier quote string or space
-