• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

ORA-01031: insufficient privileges when creating a materialized view

by admin

What is a Materialized View

A materialized view is a replica of a target master from a single point in time. The concept was first introduced with Oracle7 termed as SNAPSHOT. In Oracle release 7.1.6 snapshots were enhanced to enable DMLs along with a new terminology, updatable snapshots. In Oracle 7.3 the primary key snapshots were commenced. Subquery snapshots, support of LOB datatypes and offline instantiation are some of the new features released with Oracle8. With Oracle 8.1.6 snapshots started to be used in data warehouse environments so a new terminology materialized view was introduced to address both distributed and data warehouse materialized views. The most remarkable MVIEW enhancements in Oracle9 are the multitier materialized views and support for user-defined types.

The Problem

Following error were obeserved from the Oracle server when the “CREATE MATERIALIZED VIEW” script was executed:

where    tab2.year >   to_number(to_char(sysdate, 'YYYY')) - 4
                                       *
ERROR at line 36:
ORA-01031: insufficient privileges

The Solution

If you try to create a materialized view based on tables in a different schema, you need the privilege

GLOBAL QUERY REWRITE

as well as

CREATE TABLE
CREATE MATERIALIZED VIEW

You can grant the privilege as shown below:

Grant the privileges:
grant GLOBAL QUERY REWRITE to scott;
grant CREATE TABLE to scott;
grant CREATE MATERIALIZED VIEW to scott;

Verify your users privileges:

connect scott/tiger

select * from user_sys_privs;

USERNAME                       PRIVILEGE                                ADM
------------------------------ ---------------------------------------- ---
EKSTERN                        CREATE SESSION                           NO
EKSTERN                        CREATE TABLE                             NO
EKSTERN                        CREATE MATERIALIZED VIEW                 NO
EKSTERN                        GLOBAL QUERY REWRITE                     NO

This should fix your ORA-01031 problems.

Filed Under: Linux

Some more articles you might also be interested in …

  1. How to use auditd to monitor a file deletion in Linux
  2. ssh-add Command Examples in Linux
  3. dunstify: command not found
  4. i3: command not found
  5. avahi-browse: command not found
  6. hashcat Command Examples in Linux
  7. krita Command Examples in Linux
  8. dirb Command Examples in Linux
  9. User Unable To Edit crontab, Error: “/tmp/crontab.Lm34gsJV: Permission denied”
  10. How to increase swap space on Linux

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright