SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Views in Oracle 10g
Version 1.0
Rushdi Shams, Dept of CSE, KUET 1
What is a View
 View is a virtual table.
 It does not contain any data.
 Views, however, are saved in the
database just like tables.
 So, views are database objects.
 A view is simply a window to a database
and represents a particular perspective
to the user.
Rushdi Shams, Dept of CSE, KUET 2
What is a View
 Views are similar to queries in that
respect that they too derive a result table
– which is virtual from the actual base
table.
 The difference between views and
queries is – views can be queried as well!
Rushdi Shams, Dept of CSE, KUET 3
Advantage of View
 I said – Views are windows to the
database tables.
 Windows are used to see the outside
world.
 So, is view used to only see the outside
world?
Not at all!
Rushdi Shams, Dept of CSE, KUET 4
Advantage of View
 The main point of view is to restrict what
you can see in the underlying database
table by selective columns.
 They can be used to make complex queries
easy. A user can use a simple query on a
view to display data from multiple tables,
without having the knowledge of how to
join tables in queries.
 Different views can be created from the
same data as per the requirements of
different types of use groups.
Rushdi Shams, Dept of CSE, KUET 5
Our Table
Rushdi Shams, Dept of CSE, KUET 6
 This is our table. We will play with this table
to understand views.
Creating a View
Rushdi Shams, Dept of CSE, KUET 7
 We are now creating a view named test_view
that selects all records of CSD students
Querying the View
Rushdi Shams, Dept of CSE, KUET 8
 As we said earlier, we can query a view, we
have selected everything test_view provides.
Querying the View
Rushdi Shams, Dept of CSE, KUET 9
 In this case, we have filtered the result found
from the view with WHERE clause.
View makes Complex Query Simple
Rushdi Shams, Dept of CSE, KUET 10
 In SQL, the query we have made in the
previous slide should look like this.
 Which one is simpler?
Creating another View
Rushdi Shams, Dept of CSE, KUET 11
 This time we are creating another view
named test_view_2 which will contain the
records of BSD students.
Querying the Second View
Rushdi Shams, Dept of CSE, KUET 12
 Again we have queried the second view and
found appropriate records.
Simplicity
 This property is called simplicity
 The student data are for the whole
university
 We have simplified the data so that BSD
people won’t have to bother about CSD
people and vice versa.
Rushdi Shams, Dept of CSE, KUET 13
Creating the Third View
Rushdi Shams, Dept of CSE, KUET 14
 test_view_3 is created.
 The third line takes the months between the
current date (sysdate) and the date on birthday
column. Then divides it by 12 to get the year.
Then the whole number is passed as argument
of FLOOR function. That is the age of every
entry in the table.
Querying the View
Rushdi Shams, Dept of CSE, KUET 15
Functionality
 Another property of views.
 It means that we can provide the user
AGE and the user may never ever be
able to know that there is actually no
column such as AGE. AGE is actually
derived from other columns of the table.
Rushdi Shams, Dept of CSE, KUET 16
Security
 It is the third property of views.
 It is an extension of SIMPLICITY
property.
 BSD student records are safe now from
CSD students (As CSD students are
technologically smart )
 Do you think teachers will allow you to
see their salaries?
Rushdi Shams, Dept of CSE, KUET 17
Updating through Views
 Now we will take a look into issues we
need to know while updating tables
through views.
Rushdi Shams, Dept of CSE, KUET 18
Creating Fourth View
Rushdi Shams, Dept of CSE, KUET 19
 We have created test_view_4 which does not
have all the columns of the table.
Querying the View
Rushdi Shams, Dept of CSE, KUET 20
Our View 1 and View 4
Rushdi Shams, Dept of CSE, KUET 21
What We can do View 1?
Rushdi Shams, Dept of CSE, KUET 22
 we can insert a new row into the view
 delete an existing record from a view
 update an existing field in the view.
Problem updating through View 4
 suppose we wished to insert a record for a new
student, F, M, BSD. We would have to insert the
record null, F, M, null, null, BSD into the
underlying students table.
 This attempt will fail since studentNo (the table’s
primary key) must not be null.
23Rushdi Shams, Dept of CSE, KUET
To make a View Updatable
Rushdi Shams, Dept of CSE, KUET 24
Updating through an Updatable
View
Rushdi Shams, Dept of CSE, KUET 25
Querying the Updated View
Rushdi Shams, Dept of CSE, KUET 26
Inserting through a Wrong
View
Rushdi Shams, Dept of CSE, KUET 27
 Now, we are trying to enter a student of BSD
through a view (view 1) created for CSD
students.
The Result!
Rushdi Shams, Dept of CSE, KUET 28
 The view inserted it into the table but it cannot
be queried with view 1
 You can query it through view 2 (created for
BSD students)
The Solution
Rushdi Shams, Dept of CSE, KUET 29
 We have changed the CREATE VIEW statement
for our view 1 by adding WITH CHECK OPTION
 Now we are attempting to insert records for BSD
students through a view created for CSD
students.
The Result
Rushdi Shams, Dept of CSE, KUET 30
 Oracle got you!
 You cannot violate that when you have
created the view with a WITH CHECK
OPTION
Dropping the Views
Rushdi Shams, Dept of CSE, KUET 31
 Finally, we are dropping all the four views
with DROP VIEW option.
References
 Database Systems (Third Edition) by Paul
Beynon-Davies
 Structured Query Language (SQL): A
Practical Introduction by Akil I. Din
 Oracle forums at
http://forums.oracle.com/forums/thread.j
spa?threadID=378783 [21 March 2008]
 Geek Interview at
http://www.geekinterview.com/question_
details/338 [21 March 2008]
Rushdi Shams, Dept of CSE, KUET 32

Weitere ähnliche Inhalte

Mehr von Rushdi Shams

Syntax and semantics
Syntax and semanticsSyntax and semantics
Syntax and semanticsRushdi Shams
 
Propositional logic
Propositional logicPropositional logic
Propositional logicRushdi Shams
 
Probabilistic logic
Probabilistic logicProbabilistic logic
Probabilistic logicRushdi Shams
 
Knowledge structure
Knowledge structureKnowledge structure
Knowledge structureRushdi Shams
 
Knowledge representation
Knowledge representationKnowledge representation
Knowledge representationRushdi Shams
 
L5 understanding hacking
L5  understanding hackingL5  understanding hacking
L5 understanding hackingRushdi Shams
 
L2 Intrusion Detection System (IDS)
L2  Intrusion Detection System (IDS)L2  Intrusion Detection System (IDS)
L2 Intrusion Detection System (IDS)Rushdi Shams
 
L2 l3 l4 software process models
L2 l3 l4  software process modelsL2 l3 l4  software process models
L2 l3 l4 software process modelsRushdi Shams
 
L1 overview of software engineering
L1  overview of software engineeringL1  overview of software engineering
L1 overview of software engineeringRushdi Shams
 
L13 why software fails
L13  why software failsL13  why software fails
L13 why software failsRushdi Shams
 
Lecture 14,15 and 16 file systems
Lecture 14,15 and 16  file systemsLecture 14,15 and 16  file systems
Lecture 14,15 and 16 file systemsRushdi Shams
 
Lecture 11,12 and 13 deadlocks
Lecture 11,12 and 13  deadlocksLecture 11,12 and 13  deadlocks
Lecture 11,12 and 13 deadlocksRushdi Shams
 
Lecture 7, 8, 9 and 10 Inter Process Communication (IPC) in Operating Systems
Lecture 7, 8, 9 and 10  Inter Process Communication (IPC) in Operating SystemsLecture 7, 8, 9 and 10  Inter Process Communication (IPC) in Operating Systems
Lecture 7, 8, 9 and 10 Inter Process Communication (IPC) in Operating SystemsRushdi Shams
 
Lecture 5, 6 and 7 cpu scheduling
Lecture 5, 6 and 7  cpu schedulingLecture 5, 6 and 7  cpu scheduling
Lecture 5, 6 and 7 cpu schedulingRushdi Shams
 

Mehr von Rushdi Shams (20)

Syntax and semantics
Syntax and semanticsSyntax and semantics
Syntax and semantics
 
Propositional logic
Propositional logicPropositional logic
Propositional logic
 
Probabilistic logic
Probabilistic logicProbabilistic logic
Probabilistic logic
 
L15 fuzzy logic
L15  fuzzy logicL15  fuzzy logic
L15 fuzzy logic
 
Knowledge structure
Knowledge structureKnowledge structure
Knowledge structure
 
Knowledge representation
Knowledge representationKnowledge representation
Knowledge representation
 
First order logic
First order logicFirst order logic
First order logic
 
Belief function
Belief functionBelief function
Belief function
 
L5 understanding hacking
L5  understanding hackingL5  understanding hacking
L5 understanding hacking
 
L4 vpn
L4  vpnL4  vpn
L4 vpn
 
L3 defense
L3  defenseL3  defense
L3 defense
 
L2 Intrusion Detection System (IDS)
L2  Intrusion Detection System (IDS)L2  Intrusion Detection System (IDS)
L2 Intrusion Detection System (IDS)
 
L1 phishing
L1  phishingL1  phishing
L1 phishing
 
L2 l3 l4 software process models
L2 l3 l4  software process modelsL2 l3 l4  software process models
L2 l3 l4 software process models
 
L1 overview of software engineering
L1  overview of software engineeringL1  overview of software engineering
L1 overview of software engineering
 
L13 why software fails
L13  why software failsL13  why software fails
L13 why software fails
 
Lecture 14,15 and 16 file systems
Lecture 14,15 and 16  file systemsLecture 14,15 and 16  file systems
Lecture 14,15 and 16 file systems
 
Lecture 11,12 and 13 deadlocks
Lecture 11,12 and 13  deadlocksLecture 11,12 and 13  deadlocks
Lecture 11,12 and 13 deadlocks
 
Lecture 7, 8, 9 and 10 Inter Process Communication (IPC) in Operating Systems
Lecture 7, 8, 9 and 10  Inter Process Communication (IPC) in Operating SystemsLecture 7, 8, 9 and 10  Inter Process Communication (IPC) in Operating Systems
Lecture 7, 8, 9 and 10 Inter Process Communication (IPC) in Operating Systems
 
Lecture 5, 6 and 7 cpu scheduling
Lecture 5, 6 and 7  cpu schedulingLecture 5, 6 and 7  cpu scheduling
Lecture 5, 6 and 7 cpu scheduling
 

Kürzlich hochgeladen

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 

Kürzlich hochgeladen (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

L6 views

  • 1. Views in Oracle 10g Version 1.0 Rushdi Shams, Dept of CSE, KUET 1
  • 2. What is a View  View is a virtual table.  It does not contain any data.  Views, however, are saved in the database just like tables.  So, views are database objects.  A view is simply a window to a database and represents a particular perspective to the user. Rushdi Shams, Dept of CSE, KUET 2
  • 3. What is a View  Views are similar to queries in that respect that they too derive a result table – which is virtual from the actual base table.  The difference between views and queries is – views can be queried as well! Rushdi Shams, Dept of CSE, KUET 3
  • 4. Advantage of View  I said – Views are windows to the database tables.  Windows are used to see the outside world.  So, is view used to only see the outside world? Not at all! Rushdi Shams, Dept of CSE, KUET 4
  • 5. Advantage of View  The main point of view is to restrict what you can see in the underlying database table by selective columns.  They can be used to make complex queries easy. A user can use a simple query on a view to display data from multiple tables, without having the knowledge of how to join tables in queries.  Different views can be created from the same data as per the requirements of different types of use groups. Rushdi Shams, Dept of CSE, KUET 5
  • 6. Our Table Rushdi Shams, Dept of CSE, KUET 6  This is our table. We will play with this table to understand views.
  • 7. Creating a View Rushdi Shams, Dept of CSE, KUET 7  We are now creating a view named test_view that selects all records of CSD students
  • 8. Querying the View Rushdi Shams, Dept of CSE, KUET 8  As we said earlier, we can query a view, we have selected everything test_view provides.
  • 9. Querying the View Rushdi Shams, Dept of CSE, KUET 9  In this case, we have filtered the result found from the view with WHERE clause.
  • 10. View makes Complex Query Simple Rushdi Shams, Dept of CSE, KUET 10  In SQL, the query we have made in the previous slide should look like this.  Which one is simpler?
  • 11. Creating another View Rushdi Shams, Dept of CSE, KUET 11  This time we are creating another view named test_view_2 which will contain the records of BSD students.
  • 12. Querying the Second View Rushdi Shams, Dept of CSE, KUET 12  Again we have queried the second view and found appropriate records.
  • 13. Simplicity  This property is called simplicity  The student data are for the whole university  We have simplified the data so that BSD people won’t have to bother about CSD people and vice versa. Rushdi Shams, Dept of CSE, KUET 13
  • 14. Creating the Third View Rushdi Shams, Dept of CSE, KUET 14  test_view_3 is created.  The third line takes the months between the current date (sysdate) and the date on birthday column. Then divides it by 12 to get the year. Then the whole number is passed as argument of FLOOR function. That is the age of every entry in the table.
  • 15. Querying the View Rushdi Shams, Dept of CSE, KUET 15
  • 16. Functionality  Another property of views.  It means that we can provide the user AGE and the user may never ever be able to know that there is actually no column such as AGE. AGE is actually derived from other columns of the table. Rushdi Shams, Dept of CSE, KUET 16
  • 17. Security  It is the third property of views.  It is an extension of SIMPLICITY property.  BSD student records are safe now from CSD students (As CSD students are technologically smart )  Do you think teachers will allow you to see their salaries? Rushdi Shams, Dept of CSE, KUET 17
  • 18. Updating through Views  Now we will take a look into issues we need to know while updating tables through views. Rushdi Shams, Dept of CSE, KUET 18
  • 19. Creating Fourth View Rushdi Shams, Dept of CSE, KUET 19  We have created test_view_4 which does not have all the columns of the table.
  • 20. Querying the View Rushdi Shams, Dept of CSE, KUET 20
  • 21. Our View 1 and View 4 Rushdi Shams, Dept of CSE, KUET 21
  • 22. What We can do View 1? Rushdi Shams, Dept of CSE, KUET 22  we can insert a new row into the view  delete an existing record from a view  update an existing field in the view.
  • 23. Problem updating through View 4  suppose we wished to insert a record for a new student, F, M, BSD. We would have to insert the record null, F, M, null, null, BSD into the underlying students table.  This attempt will fail since studentNo (the table’s primary key) must not be null. 23Rushdi Shams, Dept of CSE, KUET
  • 24. To make a View Updatable Rushdi Shams, Dept of CSE, KUET 24
  • 25. Updating through an Updatable View Rushdi Shams, Dept of CSE, KUET 25
  • 26. Querying the Updated View Rushdi Shams, Dept of CSE, KUET 26
  • 27. Inserting through a Wrong View Rushdi Shams, Dept of CSE, KUET 27  Now, we are trying to enter a student of BSD through a view (view 1) created for CSD students.
  • 28. The Result! Rushdi Shams, Dept of CSE, KUET 28  The view inserted it into the table but it cannot be queried with view 1  You can query it through view 2 (created for BSD students)
  • 29. The Solution Rushdi Shams, Dept of CSE, KUET 29  We have changed the CREATE VIEW statement for our view 1 by adding WITH CHECK OPTION  Now we are attempting to insert records for BSD students through a view created for CSD students.
  • 30. The Result Rushdi Shams, Dept of CSE, KUET 30  Oracle got you!  You cannot violate that when you have created the view with a WITH CHECK OPTION
  • 31. Dropping the Views Rushdi Shams, Dept of CSE, KUET 31  Finally, we are dropping all the four views with DROP VIEW option.
  • 32. References  Database Systems (Third Edition) by Paul Beynon-Davies  Structured Query Language (SQL): A Practical Introduction by Akil I. Din  Oracle forums at http://forums.oracle.com/forums/thread.j spa?threadID=378783 [21 March 2008]  Geek Interview at http://www.geekinterview.com/question_ details/338 [21 March 2008] Rushdi Shams, Dept of CSE, KUET 32