× Heads up!

Aqua Data Studio / nhilam

Follow
IDE for Relational Databases
×
ivangron reported 2015-03-06T17:49:37Z  · raghavsingh last modified 2016-02-02T03:52:37Z

Postgres 9.3 -> Support -> Materialized views


customer request
Priority Major
Complexity Unknown
Component DB - PostgreSQL
Version 17.0

Postgres 9.3 added a new DDLs for supporting MATERIALIZED VIEWS object.  To support we need to create the tree nodes, extraction & scripting of the objects and add the object type to the object search tool.

To create a MATERIALIZED VIEW, use the below SQL to first create the table and then the mat view based on the table:

1. CREATE TABLE matviews (

  mv_name NAME NOT NULL PRIMARY KEY
  , v_name NAME NOT NULL
  , last_refresh TIMESTAMP WITH TIME ZONE
);
 
2. CREATE OR REPLACE FUNCTION create_matview(NAME, NAME)
 RETURNS VOID
 SECURITY DEFINER
 LANGUAGE plpgsql AS '
 DECLARE
     matview ALIAS FOR $1;
     view_name ALIAS FOR $2;
     entry matviews%ROWTYPE;
 BEGIN
     SELECT * INTO entry FROM matviews WHERE mv_name = matview;
 
     IF FOUND THEN
         RAISE EXCEPTION ''Materialized view ''''%'''' already exists.'',
           matview;
     END IF;
 
     EXECUTE ''REVOKE ALL ON '' || view_name || '' FROM PUBLIC''; 
 
     EXECUTE ''GRANT SELECT ON '' || view_name || '' TO PUBLIC'';
 
     EXECUTE ''CREATE TABLE '' || matview || '' AS SELECT * FROM '' || view_name;
 
     EXECUTE ''REVOKE ALL ON '' || matview || '' FROM PUBLIC'';
 
     EXECUTE ''GRANT SELECT ON '' || matview || '' TO PUBLIC'';
 
     INSERT INTO matviews (mv_name, v_name, last_refresh)
       VALUES (matview, view_name, CURRENT_TIMESTAMP); 
     
     RETURN;
 END
 ';

 

3. They also added EVENT TRIGGERS. would need to create a tree node, extraction and scripting of this object as well.

15 attachments

Issue #13126

Closed
Fixed
Resolved 2015-12-16T17:04:08Z
 
 
Completion
No due date
Fixed Build v17.0.0-ga-5, v18.0.0-dev-31
No time estimate

About AquaClusters Privacy Policy Support Version - 19.0.2-4 AquaFold, Inc Copyright © 2007-2017