Package org.h2.table
Class TableView
- java.lang.Object
-
- org.h2.engine.DbObject
-
- org.h2.schema.SchemaObject
-
- org.h2.table.Table
-
- org.h2.table.QueryExpressionTable
-
- org.h2.table.TableView
-
- All Implemented Interfaces:
HasSQL
public final class TableView extends QueryExpressionTable
A view is a virtual table that is defined by a query.
-
-
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 Constructor Description TableView(Schema schema, int id, java.lang.String name, java.lang.String querySQL, Column[] columnTemplates, SessionLocal session)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanDrop()Check if this table can be dropped.static voidclearIndexCaches(Database database)Clear the cached indexes for all sessions.protected QueryExpressionIndexcreateIndex(SessionLocal session, int[] masks)java.lang.StringgetCreateSQL()Construct the CREATE ...java.lang.StringgetCreateSQL(boolean orReplace, boolean force)Generate "CREATE" SQL statement for the view.java.lang.StringgetCreateSQLForCopy(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 tablejava.lang.StringgetDropSQL()Construct a DROP ...longgetMaxDataModificationId()Get the last data modification id.QueryScopegetQueryScope()Returns the scope of this tablejava.lang.StringgetQuerySQL()IndexgetScanIndex(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, AllColumnsForPlan allColumnsSet)Get the scan index for this table.java.util.List<Table>getTables()TableTypegetTableType()Get the table type nameQuerygetTopQuery()booleanisDeterministic()Check if the table is deterministic.booleanisInvalid()Check if this view is currently invalid.DbExceptionrecompile(SessionLocal session, boolean force, boolean clearIndexCache)Re-compile the view query and all views that depend on this object.voidremoveChildrenAndResources(SessionLocal session)Delete all dependent children objects and resources of this object.voidreplace(java.lang.String querySQL, Column[] newColumnTemplates, SessionLocal session, boolean force)Try to replace the SQL statement of the view and re-compile this and all dependent views.-
Methods inherited from class org.h2.table.QueryExpressionTable
addDependencies, addIndex, addRow, canGetRowCount, canReference, checkSupportAlter, close, createQueryColumnTemplateList, getBestPlanItem, getIndexes, getParameterOffset, getQuery, getRowCount, getRowCountApproximation, getScanIndex, isInsertable, isQueryComparable, isView, removeRow, truncate
-
Methods inherited from class org.h2.table.Table
addConstraint, addDependentMaterializedView, addDependentView, addSequence, addSynonym, addTrigger, 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, getTemplateRow, getTemplateSimpleRow, getTriggers, getType, getVisibleColumns, hasSelectTrigger, isGlobalTemporary, isLockedExclusively, isLockedExclusivelyBy, isPersistData, isPersistIndexes, isRowLockable, lock, lockRow, 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, equals, getComment, getCreateSQLForMeta, getDatabase, 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 Detail
-
TableView
public TableView(Schema schema, int id, java.lang.String name, java.lang.String querySQL, Column[] columnTemplates, SessionLocal session)
-
-
Method Detail
-
createIndex
protected QueryExpressionIndex createIndex(SessionLocal session, int[] masks)
-
replace
public void replace(java.lang.String querySQL, Column[] newColumnTemplates, SessionLocal session, boolean force)Try to replace the SQL statement of the view and re-compile this and all dependent views.- Parameters:
querySQL- the SQL statementnewColumnTemplates- the columnssession- the sessionforce- if errors should be ignored
-
recompile
public DbException recompile(SessionLocal session, boolean force, boolean clearIndexCache)
Re-compile the view query and all views that depend on this object.- Parameters:
session- the sessionforce- if exceptions should be ignoredclearIndexCache- if we need to clear view index cache- Returns:
- the exception if re-compiling this or any dependent view failed (only when force is disabled)
-
isInvalid
public boolean isInvalid()
Check if this view is currently invalid.- Returns:
- true if it is
-
getTopQuery
public Query getTopQuery()
- Specified by:
getTopQueryin classQueryExpressionTable
-
getDropSQL
public java.lang.String getDropSQL()
Description copied from class:DbObjectConstruct a DROP ... SQL statement for this object.- Overrides:
getDropSQLin classDbObject- Returns:
- the SQL statement
-
getCreateSQLForCopy
public java.lang.String getCreateSQLForCopy(Table table, java.lang.String quotedName)
Description copied from class:DbObjectBuild 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- Overrides:
getCreateSQLForCopyin classDbObject- Parameters:
table- the new tablequotedName- the quoted name- Returns:
- the SQL statement
-
getCreateSQL
public java.lang.String getCreateSQL()
Description copied from class:DbObjectConstruct the CREATE ... SQL statement for this object.- Specified by:
getCreateSQLin classDbObject- Returns:
- the SQL statement
-
getCreateSQL
public java.lang.String getCreateSQL(boolean orReplace, boolean force)Generate "CREATE" SQL statement for the view.- Parameters:
orReplace- if true, then include the OR REPLACE clauseforce- if true, then include the FORCE clause- Returns:
- the SQL statement
-
canDrop
public boolean canDrop()
Description copied from class:TableCheck if this table can be dropped.
-
getTableType
public TableType getTableType()
Description copied from class:TableGet the table type name- Specified by:
getTableTypein classTable- Returns:
- the table type name
-
removeChildrenAndResources
public void removeChildrenAndResources(SessionLocal session)
Description copied from class:DbObjectDelete all dependent children objects and resources of this object.- Overrides:
removeChildrenAndResourcesin classTable- Parameters:
session- the session
-
clearIndexCaches
public static void clearIndexCaches(Database database)
Clear the cached indexes for all sessions.- Parameters:
database- the database
-
getQuerySQL
public java.lang.String getQuerySQL()
-
getQueryScope
public QueryScope getQueryScope()
Description copied from class:QueryExpressionTableReturns the scope of this table- Specified by:
getQueryScopein classQueryExpressionTable- Returns:
- the scope of this table
-
getScanIndex
public Index getScanIndex(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, AllColumnsForPlan allColumnsSet)
Description copied from class:TableGet the scan index for this table.- Overrides:
getScanIndexin classQueryExpressionTable- Parameters:
session- the sessionmasks- the search maskfilters- the table filtersfilter- the filter indexsortOrder- the sort orderallColumnsSet- all columns- Returns:
- the scan index
-
getMaxDataModificationId
public long getMaxDataModificationId()
Description copied from class:TableGet the last data modification id.- Overrides:
getMaxDataModificationIdin classQueryExpressionTable- Returns:
- the modification id
-
isDeterministic
public boolean isDeterministic()
Description copied from class:TableCheck if the table is deterministic.- Overrides:
isDeterministicin classQueryExpressionTable- Returns:
- true if it is
-
getTables
public java.util.List<Table> getTables()
-
-