Package org.h2.table

# Class VirtualTable

java.lang.Object
org.h2.engine.DbObject
org.h2.schema.SchemaObject
org.h2.table.Table
org.h2.table.VirtualTable

All Implemented Interfaces:
  `HasSQL`

Direct Known Subclasses:
  `DualTable`, `RangeTable`, `VirtualConstructedTable`

public abstract class VirtualTable extends Table
A base class for virtual tables.

## Field Summary

### Fields inherited from class org.h2.table.Table

`columns, compareMode, EXCLUSIVE_LOCK, READ_LOCK, TYPE_CACHED, TYPE_MEMORY, WRITE_LOCK`

### Fields 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, USER`

### Fields 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
Modifier
Constructor
Description
`protected`
`VirtualTable(Schema schema, int id, String name)`

## Method Summary

Modifier and Type
Method
Description
`Index`
`addIndex(SessionLocal session, String indexName, int indexId, IndexColumn[] cols, int uniqueColumnCount, IndexType indexType, boolean create, String indexComment)`
Create an index for this table
`void`
`addRow(SessionLocal session, Row row)`
Add a row to the table and all indexes.
`boolean`
`canDrop()`
Check if this table can be dropped.
`boolean`
`canReference()`
Check if this table can be referenced.
`void`
`checkRename()`
Check if renaming is allowed.
`void`
`checkSupportAlter()`
Check if this table supports ALTER TABLE.
`void`
`close(SessionLocal session)`
Close the table object and flush changes.
`String`
`getCreateSQL()`
Construct the CREATE ...
`List<Index>`
`getIndexes()`
Get all indexes for this table.
`StringBuilder`
`getSQL(StringBuilder builder, int sqlFlags)`
Appends the SQL statement of this object to the specified builder.
`TableType`
`getTableType()`
Get the table type name
`boolean`
`isInsertable()`
Returns whether this table is insertable.
`void`
`removeRow(SessionLocal session, Row row)`
Remove a row from the table and all indexes.
`long`
`truncate(SessionLocal session)`
Remove all rows from the table and indexes.

### Methods inherited from class org.h2.table.Table

`addConstraint, addDependencies, addDependentMaterializedView, addDependentView, addSequence, addSynonym, addTrigger, canGetRowCount, canTruncate, checkDeadlock, checkWritingAllowed, compareValues, convertInsertRow, convertUpdateRow, 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, getMaxDataModificationId, getNullRow, getOnCommitDrop, getOnCommitTruncate, getPrimaryKey, getRow, getRowCount, getRowCountApproximation, getRowFactory, getRowIdColumn, getScanIndex, getScanIndex, getSQLTableType, getTemplateRow, getTemplateSimpleRow, getTriggers, getType, getVisibleColumns, hasSelectTrigger, isDeterministic, isGlobalTemporary, isLockedExclusively, isLockedExclusivelyBy, isPersistData, isPersistIndexes, isQueryComparable, isRowLockable, isView, lock, lockRow, removeChildrenAndResources, removeColumnExpressionsDependencies, removeConstraint, removeDependentMaterializedView, removeDependentView, removeIndex, removeIndexOrTransferOwnership, removeSequence, removeSynonym, removeTrigger, rename, renameColumn, setCheckForeignKeyConstraints, setColumns, setOnCommitDrop, setOnCommitTruncate, unlock, updateRow, updateRows`

### Methods inherited from class org.h2.schema.SchemaObject

`getSchema, getSQL`

### Methods inherited from class org.h2.engine.DbObject

`equals, getComment, getCreateSQLForCopy, getCreateSQLForMeta, getDatabase, getDropSQL, getId, getModificationId, getName, hashCode, invalidate, isTemporary, isValid, setComment, setModified, setObjectName, setTemporary, toString`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.h2.util.HasSQL

`getTraceSQL`

## Constructor Details

### VirtualTable

protected VirtualTable(Schema schema, int id, String name)

## Method Details

### getSQL

public StringBuilder getSQL(StringBuilder builder, int sqlFlags)
Description copied from interface: `HasSQL`
Appends the SQL statement of this object to the specified builder.

Specified by:
  `getSQL` in interface `HasSQL`
Overrides:
  `getSQL` in class `SchemaObject`
Parameters:
  `builder` - string builder
  `sqlFlags` - formatting flags
Returns:
  the specified string builder

### close

public void close(SessionLocal session)
Description copied from class: `Table`
Close the table object and flush changes.

Specified by:
  `close` in class `Table`
Parameters:
  `session` - the session

### addIndex

public Index addIndex(SessionLocal session, String indexName, int indexId, IndexColumn[] cols, int uniqueColumnCount, IndexType indexType, boolean create, String indexComment)
Description copied from class: `Table`
Create an index for this table

Specified by:
  `addIndex` in class `Table`
Parameters:
  `session` - the session
  `indexName` - the name of the index
  `indexId` - the id
  `cols` - the index columns
  `uniqueColumnCount` - the count of unique columns
  `indexType` - the index type
  `create` - whether this is a new index
  `indexComment` - the comment
Returns:
  the index

### isInsertable

public boolean isInsertable()
Description copied from class: `Table`
Returns whether this table is insertable.

Overrides:
  `isInsertable` in class `Table`
Returns:
  whether this table is insertable

### removeRow

public void removeRow(SessionLocal session, Row row)
Description copied from class: `Table`
Remove a row from the table and all indexes.

Specified by:
  `removeRow` in class `Table`
Parameters:
  `session` - the session
  `row` - the row

### truncate

public long truncate(SessionLocal session)
Description copied from class: `Table`
Remove all rows from the table and indexes.

Specified by:
  `truncate` in class `Table`
Parameters:
  `session` - the session
Returns:
  number of removed rows, possibly including uncommitted rows

### addRow

public void addRow(SessionLocal session, Row row)
Description copied from class: `Table`
Add a row to the table and all indexes.

Specified by:
  `addRow` in class `Table`
Parameters:
  `session` - the session
  `row` - the row

### checkSupportAlter

public void checkSupportAlter()
Description copied from class: `Table`
Check if this table supports ALTER TABLE.

Specified by:
  `checkSupportAlter` in class `Table`

### getTableType

public TableType getTableType()
Description copied from class: `Table`
Get the table type name

Specified by:
  `getTableType` in class `Table`
Returns:
  the table type name

### getIndexes

public List<Index> getIndexes()
Description copied from class: `Table`
Get all indexes for this table.

Specified by:
  `getIndexes` in class `Table`
Returns:
  the list of indexes

### canReference

public boolean canReference()
Description copied from class: `Table`
Check if this table can be referenced.

Overrides:
  `canReference` in class `Table`
Returns:
  true if it can

### canDrop

public boolean canDrop()
Description copied from class: `Table`
Check if this table can be dropped.

Specified by:
  `canDrop` in class `Table`
Returns:
  true if it can

### getCreateSQL

public String getCreateSQL()
Description copied from class: `DbObject`
Construct the CREATE ... SQL statement for this object.

Specified by:
  `getCreateSQL` in class `DbObject`
Returns:
  the SQL statement

### checkRename

public void checkRename()
Description copied from class: `DbObject`
Check if renaming is allowed. Does nothing when allowed.

Overrides:
  `checkRename` in class `DbObject`