How to fix the Oracle error QSM-02180: no primary key constraint in the master table?

In this post, you’ll learn more about the Oracle ErrorQSM-02180: no primary key constraint in the master table with the details on why you receive this error and the possible solution to fix it.

Oracle Error Description

QSM-02180: no primary key constraint in the master table

Reason for the Error QSM-02180: no primary key constraint in the master table

The explain_mview assumes that the materialized view is going to be created as the Primary Key materialized view. A Primary Key materialized view can not be created if the base table does not have a primary key constraint.

How to fix the Error QSM-02180: no primary key constraint in the master table ?

You can fix this error in Oracle by following the below steps

Add a primary key constraint to the base table, or create the materialized view as Rowid MV by specifying the WITH ROWID option. If the materialized view is a Rowid MV, then it should be able to do complete refresh and even fast refresh, given that the materialized view log on the master table has a rowid.