Initialize materialized views

You must initialize a materialized view to make it available for use by the database server. To initialize it, you refresh it. A failed refresh attempt returns the materialized view to an uninitialized state.

Before creating, initializing, or refreshing materialized views, ensure that all materialized view restrictions have been met. See Restrictions on materialized views.

Note

You can also initialize all uninitialized materialized views at once using the sa_refresh_materialized_views system procedure. See sa_refresh_materialized_views system procedure.

To initialize a materialized view (Sybase Central)
  1. Connect to the database as a user with DBA authority, or as a user with INSERT permission on the materialized view.

  2. In the left pane, double-click Views.

  3. Right-click a materialized view and choose Refresh Data.

  4. Select an isolation level and click OK.

    Caution

    When you are done with this example, you should drop the materialized view you created. Otherwise, you will not be able to make schema changes to its underlying tables Employees and Departments, when trying out other examples. You cannot alter the schema of a table that has enabled, dependent materialized view. See Drop materialized views.

To initialize a materialized view (SQL)
  1. Connect to the database as a user with DBA authority, or as a user with INSERT permission on the materialized view.

  2. Execute a REFRESH MATERIALIZED VIEW statement.

Example

The following statements create a materialized view, EmployeeConfid6, and then initializes it:

CREATE MATERIALIZED VIEW EmployeeConfid6 AS
   SELECT EmployeeID, Employees.DepartmentID, SocialSecurityNumber, Salary, ManagerID,
      Departments.DepartmentName, Departments.DepartmentHeadID
   FROM Employees, Departments
   WHERE Employees.DepartmentID=Departments.DepartmentID;
REFRESH MATERIALIZED VIEW EmployeeConfid6;
Caution

When you are done with this example, you should drop the materialized view you created. Otherwise, you will not be able to make schema changes to its underlying tables Employees and Departments, when trying out other examples. You cannot alter the schema of a table that has enabled, dependent materialized view. See Drop materialized views.

See also