Top Description Fields Constructors Methods
org.h2.table

public final Class TableView

extends QueryExpressionTable
Class Inheritance
Imports
java.util.ArrayList, .List, org.h2.api.ErrorCode, org.h2.command.Prepared, .QueryScope, org.h2.command.query.AllColumnsForPlan, .Query, org.h2.engine.Database, .SessionLocal, org.h2.index.Index, .QueryExpressionIndex, .RegularQueryExpressionIndex, org.h2.message.DbException, org.h2.result.SortOrder, org.h2.schema.Schema, org.h2.util.StringUtils, .Utils

A view is a virtual table that is defined by a query.
Authors
Thomas Mueller, Nicolas Fortin, Atelier SIG, IRSTV FR CNRS 24888

Field Summary

Modifier and TypeField and Description
private Column[]
private DbException
private String
Inherited from org.h2.table.QueryExpressionTable:
tablesviewQuery

Constructor Summary

AccessConstructor and Description
public
TableView(Schema schema, int id, String name, String querySQL, Column[] columnTemplates, SessionLocal session)

Method Summary

Modifier and TypeMethod and Description
private void
public boolean
canDrop()

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

Check if this table can be dropped.

public static void
clearIndexCaches(Database
the database
database
)

Clear the cached indexes for all sessions.

private static Query
protected QueryExpressionIndex
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 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 long
public QueryScope
getQueryScope()

Implements abstract org.h2.table.QueryExpressionTable.getQueryScope.

Returns the scope of this table

public String
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.QueryExpressionTable.getScanIndex.

Get the scan index for this table.

public List<Table>
public TableType
getTableType()

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

Get the table type name

public Query
private synchronized void
init(String querySQL, Column[] columnTemplates, SessionLocal session)

private void
public boolean
isDeterministic()

Overrides org.h2.table.QueryExpressionTable.isDeterministic.

Check if the table is deterministic.

public boolean

Returns:

true if it is
isInvalid
()

Check if this view is currently invalid.

public synchronized DbException

Returns:

the exception if re-compiling this or any dependent view failed (only when force is disabled)
recompile
(SessionLocal
the session
session
,
boolean
if exceptions should be ignored
force
,
boolean
if we need to clear view index cache
clearIndexCache
)

Re-compile the view query and all views that depend on this object.

public void
removeChildrenAndResources(SessionLocal
the session
session
)

Overrides org.h2.table.Table.removeChildrenAndResources.

Delete all dependent children objects and resources of this object.

private void
public void
replace(String
the SQL statement
querySQL
,
Column[]
the columns
newColumnTemplates
,
SessionLocal
the session
session
,
boolean
if errors should be ignored
force
)

Try to replace the SQL statement of the view and re-compile this and all dependent views.

Inherited from org.h2.table.QueryExpressionTable:
addDependenciesaddIndexaddRowcanGetRowCountcanReferencecheckSupportAlterclosecreateQueryColumnTemplateListgetBestPlanItemgetIndexesgetParameterOffsetgetQuerygetRowCountgetRowCountApproximationgetScanIndexinitColumnsisInsertableisQueryComparableisViewremoveRowtruncate

Field Detail

columnTemplatesback to summary
private Column[] columnTemplates
createExceptionback to summary
private DbException createException
querySQLback to summary
private String querySQL

Constructor Detail

TableViewback to summary
public TableView(Schema schema, int id, String name, String querySQL, Column[] columnTemplates, SessionLocal session)

Method Detail

addDependentViewToTablesback to summary
private void addDependentViewToTables()
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
clearIndexCachesback to summary
public static void clearIndexCaches(Database database)

Clear the cached indexes for all sessions.

Parameters
database:Database

the database

compileViewQueryback to summary
private static Query compileViewQuery(SessionLocal session, String sql)
createIndexback to summary
protected QueryExpressionIndex createIndex(SessionLocal session, int[] masks)

Implements abstract org.h2.table.QueryExpressionTable.createIndex.

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 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
getMaxDataModificationIdback to summary
public long getMaxDataModificationId()

Overrides org.h2.table.QueryExpressionTable.getMaxDataModificationId.

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

Get the last data modification id.

Returns:long

the modification id

Annotations
@Override
getQueryScopeback to summary
public QueryScope getQueryScope()

Implements abstract org.h2.table.QueryExpressionTable.getQueryScope.

Doc from org.h2.table.QueryExpressionTable.getQueryScope.

Returns the scope of this table

Returns:QueryScope

the scope of this table

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

Overrides org.h2.table.QueryExpressionTable.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
getTablesback to summary
public List<Table> getTables()
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
getTopQueryback to summary
public Query getTopQuery()

Implements abstract org.h2.table.QueryExpressionTable.getTopQuery.

Annotations
@Override
initback to summary
private synchronized void init(String querySQL, Column[] columnTemplates, SessionLocal session)
initColumnsAndTablesback to summary
private void initColumnsAndTables(SessionLocal session)
isDeterministicback to summary
public boolean isDeterministic()

Overrides org.h2.table.QueryExpressionTable.isDeterministic.

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

Check if the table is deterministic.

Returns:boolean

true if it is

Annotations
@Override
isInvalidback to summary
public boolean isInvalid()

Check if this view is currently invalid.

Returns:boolean

true if it is

recompileback to summary
public synchronized DbException recompile(SessionLocal session, boolean force, boolean clearIndexCache)

Re-compile the view query and all views that depend on this object.

Parameters
session:SessionLocal

the session

force:boolean

if exceptions should be ignored

clearIndexCache:boolean

if we need to clear view index cache

Returns:DbException

the exception if re-compiling this or any dependent view failed (only when force is disabled)

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
removeCurrentViewFromOtherTablesback to summary
private void removeCurrentViewFromOtherTables()
replaceback to summary
public void replace(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:String

the SQL statement

newColumnTemplates:Column[]

the columns

session:SessionLocal

the session

force:boolean

if errors should be ignored