SQL> set define off SQL> declare no_primary_key exception; PRAGMA EXCEPTION_INIT (no_primary_key, -12014); begin /* Oracle does not make it easy to reliably determine if a materialized view is created with the PRIMARY KEY clause or not. So we're going to assume it is created with PRIMARY KEY, but if that fails, we'll try again without it. */ execute immediate 'ALTER MATERIALIZED VIEW MPMS.VC_ALL_KEY_MESSAGE_VOD__C_DELTA_MV1 REFRESH FORCE ON DEMAND NEXT TRUNC( SYSDATE + 1 ) + 22/24 WITH PRIMARY KEY'; exception when no_primary_key then execute immediate 'ALTER MATERIALIZED VIEW MPMS.VC_ALL_KEY_MESSAGE_VOD__C_DELTA_MV1 REFRESH FORCE ON DEMAND NEXT TRUNC( SYSDATE + 1 ) + 22/24'; when others then raise; end; >> declare no_primary_key exception; PRAGMA EXCEPTION_INIT (no_primary_key, -12014); begin /* Oracle does not make it easy to reliably determine if a materialized view is created with the PRIMARY KEY clause or not. So we're going to assume it is created with PRIMARY KEY, but if that fails, we'll try again without it. */ execute immediate 'ALTER MATERIALIZED VIEW MPMS.VC_ALL_KEY_MESSAGE_VOD__C_DELTA_MV1 REFRESH FORCE ON DEMAND NEXT TRUNC( SYSDATE + 1 ) + 22/24 WITH PRIMARY KEY'; exception when no_primary_key then execute immediate 'ALTER MATERIALIZED VIEW MPMS.VC_ALL_KEY_MESSAGE_VOD__C_DELTA_MV1 REFRESH FORCE ON DEMAND NEXT TRUNC( SYSDATE + 1 ) + 22/24'; when others then raise; end; Error at line 3 ORA-12016: materialized view does not include all primary key columns ORA-06512: at line 20 ORA-06512: at line 8 Time End: 11/2/2021 9:19:28 AM Elapsed Time for Script Execution: 44502 days 09:19:28 hours