SlideShare a Scribd company logo
Data warehouse Design Using Oracle
https://www.oercommons.org/authoring/edit/21861
Dr. Girija Narasimhan 1
OER- UNIT 3 Materialized View
Exercise Solution
Dr. Girija Narasimhan 2
1. Create materialized view "pplan_mv" to display plan_id, plan_name, plan_amount, No_of_sms_free. Change
plan_id=14 amount as “ 3000" in the phone_ plan table. Write appropriate statement, the phone_plan table
modification reflects in the "pplan_mv".
2. Write appropriate statement to insert below information only in "pplan_mv1" materialized view not in
phone_plan table.
Create appropriate materialized view statement for the given below phone_plan table
Plan_id Plan_name Plan_amount
(Rs.)
Expiry date No_of_sms_free
11 Group members 1000 10-oct-2017 50
12 Monthly gold plan 1500 12-jan-2017 60
13 SMS users 800 10-apr-2017 100
14 Student plan 300 5-aug-2017 60
Dr. Girija Narasimhan 3
3. Create materialized view "pplan_mv2" using refresh complete and using phone_plan table, change
plan_amount=900 in the plan_id=11 and use appropriate refresh option in the "pplan_mv2" after
refresh also rowid should be same for plan_id=11.
4. Insert comment "this is my second mv" in the "pplan_mv2" and delete "pplan_mv"
5. Create materialized view log on phone_plan to display row_id, plan_id, plan_name, old and new
value after updating No_of_sms_free =150 in plan_id=13. [hint: both create and display statement]
6. Create materialized view "pplan_mv3" using appropriate build method which don't have result
set.
7. Display the status of all the materialized view created earlier and change pplan_mv3 status should
be "valid" in the compile_state column.
8. Display the highest No_of_sms_free, plan_id, plan_name in "pplan_mv5" and delete the comment
in pplan_mv2
Question 1
Create materialized view "pplan_mv" to display plan_id, plan_name, plan_amount,
No_of_sms_free.
Create materialized view pplan_mv from phone_plan as select * from phone_plan
Change plan_id=14 amount as “ 3000" in the phone_ plan table.
update phone_plan set plan_amount = ‘3000’ where plan_id=14;
Write appropriate statement, the phone_plan table modification reflects in the "pplan_mv".
execute dbms_mview.refresh(‘pplan_mv’);
Dr. Girija Narasimhan 4
Plan_id Plan_name Plan_amount Expiry date No_of_sms_free
15 Sliver plan 400 14-oct-2017 45
Write appropriate statement to insert below information only in "pplan_mv1" materialized view
not in phone_plan table.
Create materialized view pplan_mv1 for update as select * from phone_plan;
INSERT into pplan_mv1 values(15,’Sliver plan’,’400’,’14-oct-2017’,45);
Question 2
Dr. Girija Narasimhan 5
Question 3
Create materialized view "pplan_mv2" using refresh complete and using
phone_plan table, change plan_amount=900 in the plan_id=11 and use
appropriate refresh option in the "pplan_mv2" after refresh also rowid
should be same for plan_id=11.
Create materialized view pplan_mv2 refresh complete as select * from
phone_plan;
update phone_plan set plan_amount = ‘900’ where plan_id=11;
Execute DBMS_MVIEW.REFRESH(LIST => 'pplan_mv2', method=>'F');
Dr. Girija Narasimhan 6
Question 4
Insert comment "this is my second mv" in the "pplan_mv2"
comment on materialized view pplan_mv2 is 'This is my second mv';
delete "pplan_mv"
drop materialized view pplan_mv;
Dr. Girija Narasimhan 7
Question 5
Create materialized view log on phone_plan to display row_id, plan_id, plan_name,
old and new value after updating No_of_sms_free =150 in plan_id=13. [hint: both
create and display statement]
Create materialized view log on phone_plan with row_id,primary key including new
values;
update phone_plan set No_of_sms_free= 150 where plan_id=13;
Select M_row$$,plan_id,plan_name,old_news$$ from mlog$_phone_plan
Dr. Girija Narasimhan 8
Question 6
Create materialized view "pplan_mv3" using appropriate build method which don't have result
set.
Create materialized view pplan_mv3 build deferred as select * from phone_plan
Question 7
Display the status of all the materialized view created earlier and change pplan_mv3 status
should be "valid" in the compile_state column.
ALTER MATERIALIZED VIEW pplan_mv3 COMPILE;
SELECT MVIEW_NAME, STALENESS, LAST_REFRESH_TYPE, COMPILE_STATE FROM USER_MVIEWS
ORDER BY MVIEW_NAME;
Dr. Girija Narasimhan 9
Question 8
Display the highest No_of_sms_free, plan_id, plan_name in "pplan_mv5"
Create materialized view pplan_mv5 as select Max(No_of_sms_free), plan_id,
plan_name from phone_plan
Delete the comment in pplan_mv2
comment on materialized view pplan_mv2 is ‘ ‘;
Dr. Girija Narasimhan 10

More Related Content

More from Girija Muscut

More from Girija Muscut (20)

Tamil Nalvar
Tamil Nalvar Tamil Nalvar
Tamil Nalvar
 
Visualization using Tableau
Visualization using TableauVisualization using Tableau
Visualization using Tableau
 
Introduction to ml
Introduction to mlIntroduction to ml
Introduction to ml
 
Effective Visualization with Tableau
Effective Visualization with TableauEffective Visualization with Tableau
Effective Visualization with Tableau
 
Guruvayoor song with audio-Udayasthamana puja
Guruvayoor song with audio-Udayasthamana puja Guruvayoor song with audio-Udayasthamana puja
Guruvayoor song with audio-Udayasthamana puja
 
Lakshmi lalli with audio
Lakshmi lalli with audioLakshmi lalli with audio
Lakshmi lalli with audio
 
Bagyada laskhmi purandara dasa
Bagyada laskhmi purandara dasaBagyada laskhmi purandara dasa
Bagyada laskhmi purandara dasa
 
Lakshmi lalli
Lakshmi lalliLakshmi lalli
Lakshmi lalli
 
Amba nee irangaayenil - papanasam sivan song
Amba nee irangaayenil - papanasam sivan songAmba nee irangaayenil - papanasam sivan song
Amba nee irangaayenil - papanasam sivan song
 
Mahalakshmi jagan madha - papanasm sivan tamil song
Mahalakshmi jagan madha  - papanasm sivan tamil songMahalakshmi jagan madha  - papanasm sivan tamil song
Mahalakshmi jagan madha - papanasm sivan tamil song
 
Sowbhagayaha laskhmi varuvai nee tamil song
Sowbhagayaha laskhmi varuvai nee tamil songSowbhagayaha laskhmi varuvai nee tamil song
Sowbhagayaha laskhmi varuvai nee tamil song
 
Bega baro Bega baro Neela Megha Varna-Vadhiraja Theertha
Bega baro Bega baro Neela Megha Varna-Vadhiraja TheerthaBega baro Bega baro Neela Megha Varna-Vadhiraja Theertha
Bega baro Bega baro Neela Megha Varna-Vadhiraja Theertha
 
Rama Nama Bhajan
Rama Nama BhajanRama Nama Bhajan
Rama Nama Bhajan
 
Saratha devi song 1
Saratha devi song 1Saratha devi song 1
Saratha devi song 1
 
Saraswathi bhajan 1 with tamil meaning
Saraswathi bhajan 1 with tamil meaningSaraswathi bhajan 1 with tamil meaning
Saraswathi bhajan 1 with tamil meaning
 
Aneyu karadare -Purandara Dasar.
Aneyu karadare -Purandara Dasar.Aneyu karadare -Purandara Dasar.
Aneyu karadare -Purandara Dasar.
 
Maithriam Bhajatha with tamil meaning (lyrics)
Maithriam Bhajatha with tamil meaning (lyrics)Maithriam Bhajatha with tamil meaning (lyrics)
Maithriam Bhajatha with tamil meaning (lyrics)
 
Unit 4 scd2-exercise 1-solution
Unit 4 scd2-exercise 1-solutionUnit 4 scd2-exercise 1-solution
Unit 4 scd2-exercise 1-solution
 
Unit 2 - Slowly Changing Dimension Type 1 (SCD1) (insert)
Unit 2  - Slowly Changing Dimension Type 1 (SCD1) (insert)Unit 2  - Slowly Changing Dimension Type 1 (SCD1) (insert)
Unit 2 - Slowly Changing Dimension Type 1 (SCD1) (insert)
 
Slowly Changing Dimension Type 1 (SCD 1) exercise 2 solution insert and update
Slowly Changing Dimension Type 1 (SCD 1) exercise 2 solution insert and updateSlowly Changing Dimension Type 1 (SCD 1) exercise 2 solution insert and update
Slowly Changing Dimension Type 1 (SCD 1) exercise 2 solution insert and update
 

Recently uploaded

AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
Alluxio, Inc.
 

Recently uploaded (20)

SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdf
 
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
AI/ML Infra Meetup | Improve Speed and GPU Utilization for Model Training & S...
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
Abortion ^Clinic ^%[+971588192166''] Abortion Pill Al Ain (?@?) Abortion Pill...
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 

OER Unit 3 -Materialized view exercise solution

  • 1. Data warehouse Design Using Oracle https://www.oercommons.org/authoring/edit/21861 Dr. Girija Narasimhan 1 OER- UNIT 3 Materialized View Exercise Solution
  • 2. Dr. Girija Narasimhan 2 1. Create materialized view "pplan_mv" to display plan_id, plan_name, plan_amount, No_of_sms_free. Change plan_id=14 amount as “ 3000" in the phone_ plan table. Write appropriate statement, the phone_plan table modification reflects in the "pplan_mv". 2. Write appropriate statement to insert below information only in "pplan_mv1" materialized view not in phone_plan table. Create appropriate materialized view statement for the given below phone_plan table Plan_id Plan_name Plan_amount (Rs.) Expiry date No_of_sms_free 11 Group members 1000 10-oct-2017 50 12 Monthly gold plan 1500 12-jan-2017 60 13 SMS users 800 10-apr-2017 100 14 Student plan 300 5-aug-2017 60
  • 3. Dr. Girija Narasimhan 3 3. Create materialized view "pplan_mv2" using refresh complete and using phone_plan table, change plan_amount=900 in the plan_id=11 and use appropriate refresh option in the "pplan_mv2" after refresh also rowid should be same for plan_id=11. 4. Insert comment "this is my second mv" in the "pplan_mv2" and delete "pplan_mv" 5. Create materialized view log on phone_plan to display row_id, plan_id, plan_name, old and new value after updating No_of_sms_free =150 in plan_id=13. [hint: both create and display statement] 6. Create materialized view "pplan_mv3" using appropriate build method which don't have result set. 7. Display the status of all the materialized view created earlier and change pplan_mv3 status should be "valid" in the compile_state column. 8. Display the highest No_of_sms_free, plan_id, plan_name in "pplan_mv5" and delete the comment in pplan_mv2
  • 4. Question 1 Create materialized view "pplan_mv" to display plan_id, plan_name, plan_amount, No_of_sms_free. Create materialized view pplan_mv from phone_plan as select * from phone_plan Change plan_id=14 amount as “ 3000" in the phone_ plan table. update phone_plan set plan_amount = ‘3000’ where plan_id=14; Write appropriate statement, the phone_plan table modification reflects in the "pplan_mv". execute dbms_mview.refresh(‘pplan_mv’); Dr. Girija Narasimhan 4
  • 5. Plan_id Plan_name Plan_amount Expiry date No_of_sms_free 15 Sliver plan 400 14-oct-2017 45 Write appropriate statement to insert below information only in "pplan_mv1" materialized view not in phone_plan table. Create materialized view pplan_mv1 for update as select * from phone_plan; INSERT into pplan_mv1 values(15,’Sliver plan’,’400’,’14-oct-2017’,45); Question 2 Dr. Girija Narasimhan 5
  • 6. Question 3 Create materialized view "pplan_mv2" using refresh complete and using phone_plan table, change plan_amount=900 in the plan_id=11 and use appropriate refresh option in the "pplan_mv2" after refresh also rowid should be same for plan_id=11. Create materialized view pplan_mv2 refresh complete as select * from phone_plan; update phone_plan set plan_amount = ‘900’ where plan_id=11; Execute DBMS_MVIEW.REFRESH(LIST => 'pplan_mv2', method=>'F'); Dr. Girija Narasimhan 6
  • 7. Question 4 Insert comment "this is my second mv" in the "pplan_mv2" comment on materialized view pplan_mv2 is 'This is my second mv'; delete "pplan_mv" drop materialized view pplan_mv; Dr. Girija Narasimhan 7
  • 8. Question 5 Create materialized view log on phone_plan to display row_id, plan_id, plan_name, old and new value after updating No_of_sms_free =150 in plan_id=13. [hint: both create and display statement] Create materialized view log on phone_plan with row_id,primary key including new values; update phone_plan set No_of_sms_free= 150 where plan_id=13; Select M_row$$,plan_id,plan_name,old_news$$ from mlog$_phone_plan Dr. Girija Narasimhan 8
  • 9. Question 6 Create materialized view "pplan_mv3" using appropriate build method which don't have result set. Create materialized view pplan_mv3 build deferred as select * from phone_plan Question 7 Display the status of all the materialized view created earlier and change pplan_mv3 status should be "valid" in the compile_state column. ALTER MATERIALIZED VIEW pplan_mv3 COMPILE; SELECT MVIEW_NAME, STALENESS, LAST_REFRESH_TYPE, COMPILE_STATE FROM USER_MVIEWS ORDER BY MVIEW_NAME; Dr. Girija Narasimhan 9
  • 10. Question 8 Display the highest No_of_sms_free, plan_id, plan_name in "pplan_mv5" Create materialized view pplan_mv5 as select Max(No_of_sms_free), plan_id, plan_name from phone_plan Delete the comment in pplan_mv2 comment on materialized view pplan_mv2 is ‘ ‘; Dr. Girija Narasimhan 10