# Create a Materialized View

In 
Published 2022-12-03

This tutorial explains to you how to create a Materialized View in PostgreSQL. We use pgAdmin4 and a PostgreSQL 9.6.

Here are the steps for creating a Materialized View in PostgreSQL using the pgAdmin4 :

Right click on "Materialized Views", choose "Create", choose "Materialized View...".

In the "General" tab, enter the name, the owner , the schema where the Materialized View will be created and the description of the Sequence.

In the "Definition" tab, enter the SELECT which will define the Materialized View.

In the "Storage" tab, enter the Storage properties for the Materialized View.

Modify if you need the Parameters of the Materialized View.

In the "Security" tab, enter the Privileges and Security labels for the Materialized View (not mandatory).

You can click on SQL tab to see the SQL command used for creating that Materialized View.

Click on "Save" to create that Materialized View.

Here is the code for creating that materialized view in PostgreSQL:

CREATE MATERIALIZED VIEW public."myMV"
WITH (
    autovacuum_enabled = true
)
TABLESPACE pg_default
AS
SELECT id, firstname, surname
    FROM "mySchema"."EMP"
WITH DATA;
 
ALTER TABLE public."myMV"
    OWNER TO postgres;