Package org.h2.table

# Class QueryExpressionTable

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

All Implemented Interfaces:
  `HasSQL`

Direct Known Subclasses:
  `CTE`, `DerivedTable`, `TableView`

public abstract class QueryExpressionTable extends Table
A derived table or view.

## 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`

## Method Summary

Modifier and Type
Method
Description
`final void`
`addDependencies(HashSet<DbObject> dependencies)`
Add all objects that this table depends on to the hash set.
`final Index`
`addIndex(SessionLocal session, String indexName, int indexId, IndexColumn[] cols, int uniqueColumnCount, IndexType indexType, boolean create, String indexComment)`
Create an index for this table
`final void`
`addRow(SessionLocal session, Row row)`
Add a row to the table and all indexes.
`final boolean`
`canGetRowCount(SessionLocal session)`
Check if the row count can be retrieved quickly.
`final boolean`
`canReference()`
Check if this table can be referenced.
`final void`
`checkSupportAlter()`
Check if this table supports ALTER TABLE.
`final void`
`close(SessionLocal session)`
Close the table object and flush changes.
`static List<Column>`
`createQueryColumnTemplateList(String[] cols, Query theQuery)`
Creates a list of column templates from a query (usually from WITH query, but could be any query)
`final PlanItem`
`getBestPlanItem(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, AllColumnsForPlan allColumnsSet)`
Get the best plan for the given search mask.
`final ArrayList<Index>`
`getIndexes()`
Get all indexes for this table.
`long`
`getMaxDataModificationId()`
Get the last data modification id.
`final int`
`getParameterOffset(ArrayList<Parameter> additionalParameters)`
Get the index of the first parameter.
`final Query`
`getQuery()`
`abstract QueryScope`
`getQueryScope()`
Returns the scope of this table
`final long`
`getRowCount(SessionLocal session)`
Get the row count for this table.
`final long`
`getRowCountApproximation(SessionLocal session)`
Get the approximated row count for this table.
`final Index`
`getScanIndex(SessionLocal session)`
Get the scan index to iterate through all rows.
`Index`
`getScanIndex(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, AllColumnsForPlan allColumnsSet)`
Get the scan index for this table.
`abstract Query`
`getTopQuery()`
`boolean`
`isDeterministic()`
Check if the table is deterministic.
`final boolean`
`isInsertable()`
Returns whether this table is insertable.
`boolean`
`isQueryComparable()`
Check whether the table (or view) contains no columns that prevent index conditions to be used.
`final boolean`
`isView()`
`final void`
`removeRow(SessionLocal session, Row row)`
Remove a row from the table and all indexes.
`final long`
`truncate(SessionLocal session)`
Remove all rows from the table and indexes.

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

`addConstraint, addDependentMaterializedView, addDependentView, addSequence, addSynonym, addTrigger, canDrop, canTruncate, checkDeadlock, checkWritingAllowed, compareValues, convertInsertRow, convertUpdateRow, createRow, doesColumnExist, dropMultipleColumnsConstraintsAndIndexes, findColumn, findPrimaryKey, fire, fireAfterRow, fireBeforeRow, fireRow, getCheckForeignKeyConstraints, getChildren, getColumn, getColumn, getColumn, getColumns, getCompareMode, getConstraints, getDependentMaterializedViews, getDependentViews, getDiskSpaceUsed, getIdentityColumn, getIndex, getIndexForColumn, getMainIndexColumn, getNullRow, getOnCommitDrop, getOnCommitTruncate, getPrimaryKey, getRow, getRowFactory, getRowIdColumn, getSQLTableType, getTableType, getTemplateRow, getTemplateSimpleRow, getTriggers, getType, getVisibleColumns, hasSelectTrigger, isGlobalTemporary, isLockedExclusively, isLockedExclusivelyBy, isPersistData, isPersistIndexes, isRowLockable, 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, getSQL`

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

`checkRename, getComment, getCreateSQL, getCreateSQLForCopy, getCreateSQLForMeta, getDatabase, getDropSQL, getId, getModificationId, getName, invalidate, isTemporary, isValid, 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.util.HasSQL

`getTraceSQL`

## Method Details

### createQueryColumnTemplateList

public static List<Column> createQueryColumnTemplateList(String[] cols, Query theQuery)
Creates a list of column templates from a query (usually from WITH query, but could be any query)

Parameters:
  `cols` - - an optional list of column names (can be specified by WITH clause overriding usual select names)
  `theQuery` - - the query object we want the column list for
Returns:
  a list of column object returned by withQuery

### getQuery

public final Query getQuery()

### getTopQuery

public abstract Query getTopQuery()

### close

public final 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 final 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

### isView

public final boolean isView()

Overrides:
  `isView` in class `Table`

### getBestPlanItem

public final PlanItem getBestPlanItem(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, AllColumnsForPlan allColumnsSet)
Description copied from class: `Table`
Get the best plan for the given search mask.

Overrides:
  `getBestPlanItem` in class `Table`
Parameters:
  `session` - the session
  `masks` - per-column comparison bit masks, null means 'always false', see constants in IndexCondition
  `filters` - all joined table filters
  `filter` - the current table filter index
  `sortOrder` - the sort order
  `allColumnsSet` - the set of all columns
Returns:
  the plan item

### isQueryComparable

public boolean isQueryComparable()
Description copied from class: `Table`
Check whether the table (or view) contains no columns that prevent index conditions to be used. For example, a view that contains the ROWNUM() pseudo-column prevents this.

Overrides:
  `isQueryComparable` in class `Table`
Returns:
  true if the table contains no query-comparable column

### isInsertable

public final 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 final 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

### addRow

public final 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 final void checkSupportAlter()
Description copied from class: `Table`
Check if this table supports ALTER TABLE.

Specified by:
  `checkSupportAlter` in class `Table`

### truncate

public final 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

### getRowCount

public final long getRowCount(SessionLocal session)
Description copied from class: `Table`
Get the row count for this table.

Specified by:
  `getRowCount` in class `Table`
Parameters:
  `session` - the session
Returns:
  the row count

### canGetRowCount

public final boolean canGetRowCount(SessionLocal session)
Description copied from class: `Table`
Check if the row count can be retrieved quickly.

Specified by:
  `canGetRowCount` in class `Table`
Parameters:
  `session` - the session
Returns:
  true if it can

### getRowCountApproximation

public final long getRowCountApproximation(SessionLocal session)
Description copied from class: `Table`
Get the approximated row count for this table.

Specified by:
  `getRowCountApproximation` in class `Table`
Parameters:
  `session` - the session
Returns:
  the approximated row count

### getParameterOffset

public final int getParameterOffset(ArrayList<Parameter> additionalParameters)
Get the index of the first parameter.

Parameters:
  `additionalParameters` - additional parameters
Returns:
  the index of the first parameter

### canReference

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

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

### getIndexes

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

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

### getMaxDataModificationId

public long getMaxDataModificationId()
Description copied from class: `Table`
Get the last data modification id.

Specified by:
  `getMaxDataModificationId` in class `Table`
Returns:
  the modification id

### getScanIndex

public final Index getScanIndex(SessionLocal session)
Description copied from class: `Table`
Get the scan index to iterate through all rows.

Specified by:
  `getScanIndex` in class `Table`
Parameters:
  `session` - the session
Returns:
  the index

### getScanIndex

public Index getScanIndex(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, AllColumnsForPlan allColumnsSet)
Description copied from class: `Table`
Get the scan index for this table.

Overrides:
  `getScanIndex` in class `Table`
Parameters:
  `session` - the session
  `masks` - the search mask
  `filters` - the table filters
  `filter` - the filter index
  `sortOrder` - the sort order
  `allColumnsSet` - all columns
Returns:
  the scan index

### isDeterministic

public boolean isDeterministic()
Description copied from class: `Table`
Check if the table is deterministic.

Specified by:
  `isDeterministic` in class `Table`
Returns:
  true if it is

### addDependencies

public final void addDependencies(HashSet<DbObject> dependencies)
Description copied from class: `Table`
Add all objects that this table depends on to the hash set.

Overrides:
  `addDependencies` in class `Table`
Parameters:
  `dependencies` - the current set of dependencies

### getQueryScope

public abstract QueryScope getQueryScope()
Returns the scope of this table

Returns:
  the scope of this table