Hace poco me preguntaron como se podia realizar un refresco completo de una Vista Materializada (VM) sin usar Truncate por question de consistencia de lectura. No querian que los usuarios vean una tabla vacia cuando esta refrescando la VM.
Han hecho los deberes y consultaron primero en la documentacion donde le indica, pasando TRUE al argumento del package DBMS_MVIEW.REFRESH.ATOMIC_REFRESH usaria delete. Lo han probado una y otra vez sin exito.
El comando utilizado es:
exec dbms_mview.refresh(‘MV_T1′,’C',ATOMIC_REFRESH=>TRUE)
El problema es que si no pasas una lista de VM al package SIEMPRE usara TRUNCATE, si se usa esta llamada
exec dbms_mview.refresh(‘MV_T1,MV_T2′,’C',ATOMIC_REFRESH=>TRUE)
Que engloba dos VM si se utilizaria DELETE.
En la documentacion indica esto:
“atomic_refresh
If this parameter is set to true, then the list of materialized views is refreshed in a single transaction. All of the refreshed materialized views are updated to a single point in time. If the refresh fails for any of the materialized views, none of the materialized views are updated.
If this parameter is set to false, then each of the materialized views is refreshed in a separate transaction. The number of job queue processes must be set to 1 or greater if this parameter is false.”
La confusion es que en ningun parrafo indica que tienes que pasar mas de una VM para que use DELETE, aunque si indica que tienes que pasar una lista.