REFRESH TABLE

The REFRESH TABLE statement refreshes the data in a materialized query table. The statement deletes all rows in the materialized query table and then inserts the result rows from the select-statement specified in the definition of the materialized query table.

Invocation

This statement can be embedded in an application program or issued interactively. It is an executable statement that can be dynamically prepared.

Authorization

The privileges held by the authorization ID of the statement must include at least one of the following:

  • For the table identified in the statement,
    • The system authority *OBJMGT on the table
    • The DELETE privilege on the table
    • The INSERT privilege on the table
    • The system authority *EXECUTE on the library containing the table
  • Administrative authority

For information on the system authorities corresponding to SQL privileges, see Corresponding System Authorities When Checking Privileges to a Table or View.

Syntax

Read syntax diagramSkip visual syntax diagram
                  .-,--------------.   
                  V                |   
>>-REFRESH TABLE------table-name---+---------------------------><

Description

table-name
Identifies the materialized table to be refreshed. The table-name must identify a materialized query table that exists at the current server. REFRESH TABLE evaluates the select-statement in the definition of the materialized query table to refresh the table.

Notes

Refresh use of materialized query tables: No materialized query tables are used to evaluate the select-statement during the processing of REFRESH TABLE statement.

Refresh isolation level: The isolation level used to evaluate the select-statement is either:

  • the isolation level specified on the isolation-level clause of the select-statement, or
  • if the isolation-level clause was not specified, the isolation level of the materialized query table recorded when CREATE TABLE or ALTER TABLE was issued.

Number of rows: After successful execution of a REFRESH TABLE statement, the ROW_COUNT statement information item in the SQL Diagnostics Area (or SQLERRD(3) in the SQLCA) will contain the number of rows inserted into the materialized query table.

Example

Refresh the data in the TRANSCOUNT materialized query table.

   REFRESH TABLE TRANSCOUNT