Package org.h2.table

Class MaterializedView

  • All Implemented Interfaces:
    HasSQL

    public class MaterializedView
    extends Table
    A materialized view.
    • Constructor Detail

      • MaterializedView

        public MaterializedView​(Schema schema,
                                int id,
                                java.lang.String name,
                                Table table,
                                Query query,
                                java.lang.String querySQL)
    • Method Detail

      • replace

        public void replace​(Table table,
                            Query query,
                            java.lang.String querySQL)
      • getUnderlyingTable

        public Table getUnderlyingTable()
      • getSelect

        public Query getSelect()
      • 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,
                                    java.lang.String indexName,
                                    int indexId,
                                    IndexColumn[] cols,
                                    int uniqueColumnCount,
                                    IndexType indexType,
                                    boolean create,
                                    java.lang.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,
                                              boolean isSelectCommand)
        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
      • 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 java.util.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
      • 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​(java.util.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
      • getDropSQL

        public java.lang.String getDropSQL()
        Description copied from class: DbObject
        Construct a DROP ... SQL statement for this object.
        Overrides:
        getDropSQL in class DbObject
        Returns:
        the SQL statement
      • getCreateSQLForCopy

        public java.lang.String getCreateSQLForCopy​(Table table,
                                                    java.lang.String quotedName)
        Description copied from class: DbObject
        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
        Overrides:
        getCreateSQLForCopy in class DbObject
        Parameters:
        table - the new table
        quotedName - the quoted name
        Returns:
        the SQL statement
      • getCreateSQL

        public java.lang.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
      • getCreateSQL

        public java.lang.String getCreateSQL​(boolean orReplace,
                                             boolean force)
        Generate "CREATE" SQL statement for the materialized view.
        Parameters:
        orReplace - if true, then include the OR REPLACE clause
        force - if true, then include the FORCE clause
        Returns:
        the SQL statement
      • 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
      • 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
      • removeChildrenAndResources

        public void removeChildrenAndResources​(SessionLocal session)
        Description copied from class: DbObject
        Delete all dependent children objects and resources of this object.
        Overrides:
        removeChildrenAndResources in class Table
        Parameters:
        session - the session
      • getSQL

        public java.lang.StringBuilder getSQL​(java.lang.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
      • getQuerySQL

        public java.lang.String getQuerySQL()
      • 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