Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 530727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:13:38+00:00 2026-05-13T09:13:38+00:00

I have a materialized view defined this way: CREATE MATERIALIZED VIEW M_FOO REFRESH COMPLETE

  • 0

I have a materialized view defined this way:

CREATE MATERIALIZED VIEW M_FOO
REFRESH COMPLETE ON COMMIT
AS
    SELECT FOO_ID, BAR
    FROM FOO
    WHERE BAR IS NOT NULL
    GROUP BY FOO_ID, BAR
/

COMMENT ON MATERIALIZED VIEW M_FOO IS 'Foo-Bar pairs';

I wrote as a sort of cache: the source table is huge but the number of different pairs is fairly small. I need those pairs to get them JOINed with other tables. So far so good: it absolutely speeds queries.

But I want to make sure that the view does not contain obsolete data. The underlying table is modified four or five times per month but I don’t necessarily know when. I understand that a materialized view can be defined so it updates when the source tables change. However, the docs get pretty complicate.

  1. What’s the exact syntax I need to
    use?

  2. Do I need to create a materialized
    view log?

  3. What’s the difference between fast
    and complete refresh?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:13:38+00:00Added an answer on May 13, 2026 at 9:13 am

    To take your questions in reverse order

    A FAST refresh is also known as an incremental refresh. That should give you a clue as to the difference. A COMPLETE refresh rebuilds the entire MVIEW from scratch, whereas a FAST refresh applies just the changes from DML executed against the feeder table(s).

    In order to do execute FAST refreshes you need the appropriate MVIEW LOG. This tracks changes to the data of the underlying tables, which allows Oracle to efficiently apply a delta to the materialized view, rather than querying the whole table.

    As for the syntax, here are the basics:

    SQL> create materialized view log on emp
      2  with rowid, primary key, sequence (deptno, job)
      3  including new values
      4  /
    
    Materialized view log created.
    
    SQL> create materialized view emp_mv
      2  refresh fast on commit
      3  as
      4  select deptno, job from emp
      5  group by deptno, job
      6  /
    
    Materialized view created.
    
    SQL>
    

    The ON COMMIT clause means that the MVIEW is refreshed transactionally (as opposed to ON DEMAND which is regular refresh in bulk). The REFRESH clauses specifies whether to apply incremental or complete refreshes. There are some categories of query which force the use of COMPLETE refresh, although these seem to diminish with each new version of Oracle.

    A quick test to see that it works …

    SQL> select * from emp_mv
      2  order by deptno, job
      3  /
    
        DEPTNO JOB
    ---------- ---------
            10 MANAGER
            10 PRESIDENT
            10 SALES
            20 ANALYST
            20 CLERK
            20 MANAGER
            30 CLERK
            30 MANAGER
            30 SALESMAN
            40 CLERK
            40 DOGSBODY
    
    11 rows selected.
    
    SQL>
    

    How about a new record?

    SQL> insert into emp (empno, ename, deptno, job)
      2  values (6666, 'GADGET', 40, 'INSPECTOR')
      3  /
    
    1 row created.
    
    SQL> commit
      2  /
    
    Commit complete.
    
    SQL> select * from emp_mv
      2  order by deptno, job
      3  /
    
        DEPTNO JOB
    ---------- ---------
            10 MANAGER
            10 PRESIDENT
            10 SALES
            20 ANALYST
            20 CLERK
            20 MANAGER
            30 CLERK
            30 MANAGER
            30 SALESMAN
            40 CLERK
            40 DOGSBODY
            40 INSPECTOR
    
    12 rows selected.
    
    SQL>
    

    You can find more details on the syntax in the SQL Reference. It’s also worth reading the Materialized View chapter in the Data Warehousing Guide.


    Despite the concerns of the commenters below this does work as advertised. Unfortunately the usual places for publishing demos (SQL Fiddle, db<>fiddle) do not allow materialized views. I have published something on Oracle SQL Live (free Oracle account required): I am awaiting Oracle approval for it and will update this question when it arrives.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 306k
  • Answers 306k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer L1 is typically/probably a label, associated with one particular address… May 13, 2026 at 9:13 pm
  • Editorial Team
    Editorial Team added an answer This was an RTFM. I should have called a different… May 13, 2026 at 9:13 pm
  • Editorial Team
    Editorial Team added an answer This is a floating point error, where the variable cannot… May 13, 2026 at 9:13 pm

Related Questions

I'm using MS SQL Server. When I define the database schema I define a
Question: Does Informix have a construct equivalent to Oracle's materialized view or is there
This is another stab into a problem I posted here . Please don't close
I have a script that generates DDL scripts to define materialized views for a
I have a materialized view of a complex join, which I would like to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.