Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

223
Vistas
How to alter materialized view with dependent views

I am currently having a series of materialized views View #1 and View #2 which I use for reporting.

Using PGAdmin, I want to change the code of Materialized View #1 (just change the where clause, the structure of the view remains the same), but Materialized View #2 is generated from Materialized View #1.

Is there a way to defer any of the checks so that I can make a change without dropping every subsequent view?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Nyes...

There is a solution that may not be suitable in every cases. It might be simpler to rerun the creation script of all dependent objects.

So, while the query of the materialized view cannot change without dropping the materialized view first, nothing prevents you from storing the said query in a regular view, and to create a materialized view calling this regular view. You are then free to replace (update) the regular view and then you just have to refresh the materialized view.

create table test_table(id int, txt text);
insert into test_table values (1,'one'),(2,'two');

create or replace view test_view
AS 
 select id as v_id, 
        txt as v_txt
 from test_table;
 
 
create materialized view test_mat_view
AS
 select v_id, v_txt from test_view;
 
select * from test_mat_view; 
 
  v_id | v_txt
------+-------
    1 | one
    2 | two
(2 rows)
 
create or replace view test_view
AS 
 select id as v_id, 
        'constant' as v_txt
 from test_table;
 
REFRESH materialized view test_mat_view;
  
select * from test_mat_view; 
 
 v_id |  v_txt
------+----------
    1 | constant
    2 | constant
 
drop table test_table cascade;
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda