Top Description Fields Constructors Methods
org.h2.table

public Class MaterializedView

extends Table
Class Inheritance
Imports
java.util.ArrayList, .HashSet, org.h2.command.query.AllColumnsForPlan, .Query, org.h2.engine.DbObject, .SessionLocal, org.h2.index.Index, .IndexType, org.h2.message.DbException, org.h2.result.Row, .SortOrder, org.h2.schema.Schema, org.h2.util.StringUtils

A materialized view.

Field Summary

Modifier and TypeField and Description
private Query
private String
private Table
Inherited from org.h2.table.Table:
columnscompareModeEXCLUSIVE_LOCKREAD_LOCKTYPE_CACHEDTYPE_MEMORYWRITE_LOCK

Constructor Summary

AccessConstructor and Description
public
MaterializedView(Schema schema, int id, String name, Table table, Query query, String querySQL)

Method Summary

Modifier and TypeMethod and Description
public final void
addDependencies(HashSet<DbObject>
the current set of dependencies
dependencies
)

Overrides org.h2.table.Table.addDependencies.

Add all objects that this table depends on to the hash set.

public final Index
addIndex(SessionLocal
the session
session
,
String
the name of the index
indexName
,
int
the id
indexId
,
IndexColumn[]
the index columns
cols
,
int
the count of unique columns
uniqueColumnCount
,
IndexType
the index type
indexType
,
boolean
whether this is a new index
create
,
String
the comment
indexComment
)

Implements abstract org.h2.table.Table.addIndex.

Create an index for this table

public final void
addRow(SessionLocal
the session
session
,
Row
the row
row
)

Implements abstract org.h2.table.Table.addRow.

Add a row to the table and all indexes.

public boolean
canDrop()

Implements abstract org.h2.table.Table.canDrop.

Check if this table can be dropped.

public final boolean
canGetRowCount(SessionLocal
the session
session
)

Implements abstract org.h2.table.Table.canGetRowCount.

Check if the row count can be retrieved quickly.

public final boolean
canReference()

Overrides org.h2.table.Table.canReference.

Check if this table can be referenced.

public final void
checkSupportAlter()

Implements abstract org.h2.table.Table.checkSupportAlter.

Check if this table supports ALTER TABLE.

public final void
close(SessionLocal
the session
session
)

Implements abstract org.h2.table.Table.close.

Close the table object and flush changes.

public final PlanItem
getBestPlanItem(SessionLocal
the session
session
,
int[]
per-column comparison bit masks, null means 'always false', see constants in IndexCondition
masks
,
TableFilter[]
all joined table filters
filters
,
int
the current table filter index
filter
,
SortOrder
the sort order
sortOrder
,
AllColumnsForPlan
the set of all columns
allColumnsSet
)

Overrides org.h2.table.Table.getBestPlanItem.

Get the best plan for the given search mask.

public String
getCreateSQL()

Implements abstract org.h2.engine.DbObject.getCreateSQL.

Construct the CREATE ...

public String

Returns:

the SQL statement
getCreateSQL
(boolean
if true, then include the OR REPLACE clause
orReplace
,
boolean
if true, then include the FORCE clause
force
)

Generate "CREATE" SQL statement for the materialized view.

private String
getCreateSQL(boolean orReplace, boolean force, String quotedName)

public String
getCreateSQLForCopy(Table
the new table
table
,
String
the quoted name
quotedName
)

Overrides org.h2.engine.DbObject.getCreateSQLForCopy.

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

public String
getDropSQL()

Overrides org.h2.engine.DbObject.getDropSQL.

Construct a DROP ...

public final ArrayList<Index>
getIndexes()

Implements abstract org.h2.table.Table.getIndexes.

Get all indexes for this table.

public long
getMaxDataModificationId()

Implements abstract org.h2.table.Table.getMaxDataModificationId.

Get the last data modification id.

public String
public final long
getRowCount(SessionLocal
the session
session
)

Implements abstract org.h2.table.Table.getRowCount.

Get the row count for this table.

public final long
getRowCountApproximation(SessionLocal
the session
session
)

Implements abstract org.h2.table.Table.getRowCountApproximation.

Get the approximated row count for this table.

public final Index
getScanIndex(SessionLocal
the session
session
)

Implements abstract org.h2.table.Table.getScanIndex.

Get the scan index to iterate through all rows.

public Index
getScanIndex(SessionLocal
the session
session
,
int[]
the search mask
masks
,
TableFilter[]
the table filters
filters
,
int
the filter index
filter
,
SortOrder
the sort order
sortOrder
,
AllColumnsForPlan
all columns
allColumnsSet
)

Overrides org.h2.table.Table.getScanIndex.

Get the scan index for this table.

public Query
public StringBuilder
getSQL(StringBuilder
string builder
builder
,
int
formatting flags
sqlFlags
)

Overrides org.h2.schema.SchemaObject.getSQL.

Implements org.h2.util.HasSQL.getSQL.

Appends the SQL statement of this object to the specified builder.

public TableType
getTableType()

Implements abstract org.h2.table.Table.getTableType.

Get the table type name

public Table
public boolean
isDeterministic()

Implements abstract org.h2.table.Table.isDeterministic.

Check if the table is deterministic.

public final boolean
isInsertable()

Overrides org.h2.table.Table.isInsertable.

Returns whether this table is insertable.

public boolean
isQueryComparable()

Overrides org.h2.table.Table.isQueryComparable.

Check whether the table (or view) contains no columns that prevent index conditions to be used.

public final boolean
public void
removeChildrenAndResources(SessionLocal
the session
session
)

Overrides org.h2.table.Table.removeChildrenAndResources.

Delete all dependent children objects and resources of this object.

public final void
removeRow(SessionLocal
the session
session
,
Row
the row
row
)

Implements abstract org.h2.table.Table.removeRow.

Remove a row from the table and all indexes.

public void
replace(Table table, Query query, String querySQL)

public final long
truncate(SessionLocal
the session
session
)

Implements abstract org.h2.table.Table.truncate.

Remove all rows from the table and indexes.

Inherited from org.h2.table.Table:
addConstraintaddDependentMaterializedViewaddDependentViewaddSequenceaddSynonymaddTriggercanTruncatecheckDeadlockcheckWritingAllowedcompareValuesconvertInsertRowconvertUpdateRowcreateRowdoesColumnExistdropMultipleColumnsConstraintsAndIndexesfindColumnfindPrimaryKeyfirefireAfterRowfireBeforeRowfireRowgetCheckForeignKeyConstraintsgetChildrengetColumngetColumngetColumngetColumnsgetCompareModegetConstraintsgetDependentMaterializedViewsgetDependentViewsgetDiskSpaceUsedgetIdentityColumngetIndexgetIndexForColumngetMainIndexColumngetNullRowgetOnCommitDropgetOnCommitTruncategetPrimaryKeygetRowgetRowFactorygetRowIdColumngetSQLTableTypegetTemplateRowgetTemplateSimpleRowgetTriggersgetTypegetVisibleColumnshasSelectTriggerisGlobalTemporaryisLockedExclusivelyisLockedExclusivelyByisPersistDataisPersistIndexesisRowLockablelocklockRowremoveColumnExpressionsDependenciesremoveConstraintremoveDependentMaterializedViewremoveDependentViewremoveIndexremoveIndexOrTransferOwnershipremoveSequenceremoveSynonymremoveTriggerrenamerenameColumnsetCheckForeignKeyConstraintssetColumnssetOnCommitDropsetOnCommitTruncateunlockupdateRowupdateRows

Field Detail

queryback to summary
private Query query
querySQLback to summary
private String querySQL
tableback to summary
private Table table

Constructor Detail

MaterializedViewback to summary
public MaterializedView(Schema schema, int id, String name, Table table, Query query, String querySQL)

Method Detail

addDependenciesback to summary
public final void addDependencies(HashSet<DbObject> dependencies)

Overrides org.h2.table.Table.addDependencies.

Doc from org.h2.table.Table.addDependencies.

Add all objects that this table depends on to the hash set.

Parameters
dependencies:HashSet<DbObject>

the current set of dependencies

Annotations
@Override
addIndexback to summary
public final Index addIndex(SessionLocal session, String indexName, int indexId, IndexColumn[] cols, int uniqueColumnCount, IndexType indexType, boolean create, String indexComment)

Implements abstract org.h2.table.Table.addIndex.

Doc from org.h2.table.Table.addIndex.

Create an index for this table

Parameters
session:SessionLocal

the session

indexName:String

the name of the index

indexId:int

the id

cols:IndexColumn[]

the index columns

uniqueColumnCount:int

the count of unique columns

indexType:IndexType

the index type

create:boolean

whether this is a new index

indexComment:String

the comment

Returns:Index

the index

Annotations
@Override
addRowback to summary
public final void addRow(SessionLocal session, Row row)

Implements abstract org.h2.table.Table.addRow.

Doc from org.h2.table.Table.addRow.

Add a row to the table and all indexes.

Parameters
session:SessionLocal

the session

row:Row

the row

Annotations
@Override
canDropback to summary
public boolean canDrop()

Implements abstract org.h2.table.Table.canDrop.

Doc from org.h2.table.Table.canDrop.

Check if this table can be dropped.

Returns:boolean

true if it can

Annotations
@Override
canGetRowCountback to summary
public final boolean canGetRowCount(SessionLocal session)

Implements abstract org.h2.table.Table.canGetRowCount.

Doc from org.h2.table.Table.canGetRowCount.

Check if the row count can be retrieved quickly.

Parameters
session:SessionLocal

the session

Returns:boolean

true if it can

Annotations
@Override
canReferenceback to summary
public final boolean canReference()

Overrides org.h2.table.Table.canReference.

Doc from org.h2.table.Table.canReference.

Check if this table can be referenced.

Returns:boolean

true if it can

Annotations
@Override
checkSupportAlterback to summary
public final void checkSupportAlter()

Implements abstract org.h2.table.Table.checkSupportAlter.

Doc from org.h2.table.Table.checkSupportAlter.

Check if this table supports ALTER TABLE.

Annotations
@Override
closeback to summary
public final void close(SessionLocal session)

Implements abstract org.h2.table.Table.close.

Doc from org.h2.table.Table.close.

Close the table object and flush changes.

Parameters
session:SessionLocal

the session

Annotations
@Override
getBestPlanItemback to summary
public final PlanItem getBestPlanItem(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, AllColumnsForPlan allColumnsSet)

Overrides org.h2.table.Table.getBestPlanItem.

Doc from org.h2.table.Table.getBestPlanItem.

Get the best plan for the given search mask.

Parameters
session:SessionLocal

the session

masks:int[]

per-column comparison bit masks, null means 'always false', see constants in IndexCondition

filters:TableFilter[]

all joined table filters

filter:int

the current table filter index

sortOrder:SortOrder

the sort order

allColumnsSet:AllColumnsForPlan

the set of all columns

Returns:PlanItem

the plan item

Annotations
@Override
getCreateSQLback to summary
public String getCreateSQL()

Implements abstract org.h2.engine.DbObject.getCreateSQL.

Doc from org.h2.engine.DbObject.getCreateSQL.

Construct the CREATE ... SQL statement for this object.

Returns:String

the SQL statement

Annotations
@Override
getCreateSQLback to summary
public String getCreateSQL(boolean orReplace, boolean force)

Generate "CREATE" SQL statement for the materialized view.

Parameters
orReplace:boolean

if true, then include the OR REPLACE clause

force:boolean

if true, then include the FORCE clause

Returns:String

the SQL statement

getCreateSQLback to summary
private String getCreateSQL(boolean orReplace, boolean force, String quotedName)
getCreateSQLForCopyback to summary
public String getCreateSQLForCopy(Table table, String quotedName)

Overrides org.h2.engine.DbObject.getCreateSQLForCopy.

Doc from org.h2.engine.DbObject.getCreateSQLForCopy.

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

Parameters
table:Table

the new table

quotedName:String

the quoted name

Returns:String

the SQL statement

Annotations
@Override
getDropSQLback to summary
public String getDropSQL()

Overrides org.h2.engine.DbObject.getDropSQL.

Doc from org.h2.engine.DbObject.getDropSQL.

Construct a DROP ... SQL statement for this object.

Returns:String

the SQL statement

Annotations
@Override
getIndexesback to summary
public final ArrayList<Index> getIndexes()

Implements abstract org.h2.table.Table.getIndexes.

Doc from org.h2.table.Table.getIndexes.

Get all indexes for this table.

Returns:ArrayList<Index>

the list of indexes

Annotations
@Override
getMaxDataModificationIdback to summary
public long getMaxDataModificationId()

Implements abstract org.h2.table.Table.getMaxDataModificationId.

Doc from org.h2.table.Table.getMaxDataModificationId.

Get the last data modification id.

Returns:long

the modification id

Annotations
@Override
getQuerySQLback to summary
public String getQuerySQL()
getRowCountback to summary
public final long getRowCount(SessionLocal session)

Implements abstract org.h2.table.Table.getRowCount.

Doc from org.h2.table.Table.getRowCount.

Get the row count for this table.

Parameters
session:SessionLocal

the session

Returns:long

the row count

Annotations
@Override
getRowCountApproximationback to summary
public final long getRowCountApproximation(SessionLocal session)

Implements abstract org.h2.table.Table.getRowCountApproximation.

Doc from org.h2.table.Table.getRowCountApproximation.

Get the approximated row count for this table.

Parameters
session:SessionLocal

the session

Returns:long

the approximated row count

Annotations
@Override
getScanIndexback to summary
public final Index getScanIndex(SessionLocal session)

Implements abstract org.h2.table.Table.getScanIndex.

Doc from org.h2.table.Table.getScanIndex.

Get the scan index to iterate through all rows.

Parameters
session:SessionLocal

the session

Returns:Index

the index

Annotations
@Override
getScanIndexback to summary
public Index getScanIndex(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, AllColumnsForPlan allColumnsSet)

Overrides org.h2.table.Table.getScanIndex.

Doc from org.h2.table.Table.getScanIndex.

Get the scan index for this table.

Parameters
session:SessionLocal

the session

masks:int[]

the search mask

filters:TableFilter[]

the table filters

filter:int

the filter index

sortOrder:SortOrder

the sort order

allColumnsSet:AllColumnsForPlan

all columns

Returns:Index

the scan index

Annotations
@Override
getSelectback to summary
public Query getSelect()
getSQLback to summary
public StringBuilder getSQL(StringBuilder builder, int sqlFlags)

Overrides org.h2.schema.SchemaObject.getSQL.

Implements org.h2.util.HasSQL.getSQL.

Doc from org.h2.util.HasSQL.getSQL.

Appends the SQL statement of this object to the specified builder.

Parameters
builder:StringBuilder

string builder

sqlFlags:int

formatting flags

Returns:StringBuilder

the specified string builder

Annotations
@Override
getTableTypeback to summary
public TableType getTableType()

Implements abstract org.h2.table.Table.getTableType.

Doc from org.h2.table.Table.getTableType.

Get the table type name

Returns:TableType

the table type name

Annotations
@Override
getUnderlyingTableback to summary
public Table getUnderlyingTable()
isDeterministicback to summary
public boolean isDeterministic()

Implements abstract org.h2.table.Table.isDeterministic.

Doc from org.h2.table.Table.isDeterministic.

Check if the table is deterministic.

Returns:boolean

true if it is

Annotations
@Override
isInsertableback to summary
public final boolean isInsertable()

Overrides org.h2.table.Table.isInsertable.

Doc from org.h2.table.Table.isInsertable.

Returns whether this table is insertable.

Returns:boolean

whether this table is insertable

Annotations
@Override
isQueryComparableback to summary
public boolean isQueryComparable()

Overrides org.h2.table.Table.isQueryComparable.

Doc from org.h2.table.Table.isQueryComparable.

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.

Returns:boolean

true if the table contains no query-comparable column

Annotations
@Override
isViewback to summary
public final boolean isView()

Overrides org.h2.table.Table.isView.

Annotations
@Override
removeChildrenAndResourcesback to summary
public void removeChildrenAndResources(SessionLocal session)

Overrides org.h2.table.Table.removeChildrenAndResources.

Doc from org.h2.engine.DbObject.removeChildrenAndResources.

Delete all dependent children objects and resources of this object.

Parameters
session:SessionLocal

the session

Annotations
@Override
removeRowback to summary
public final void removeRow(SessionLocal session, Row row)

Implements abstract org.h2.table.Table.removeRow.

Doc from org.h2.table.Table.removeRow.

Remove a row from the table and all indexes.

Parameters
session:SessionLocal

the session

row:Row

the row

Annotations
@Override
replaceback to summary
public void replace(Table table, Query query, String querySQL)
truncateback to summary
public final long truncate(SessionLocal session)

Implements abstract org.h2.table.Table.truncate.

Doc from org.h2.table.Table.truncate.

Remove all rows from the table and indexes.

Parameters
session:SessionLocal

the session

Returns:long

number of removed rows, possibly including uncommitted rows

Annotations
@Override