SlideShare a Scribd company logo
Creating Views  http://ecomputernotes.com
Objectives  After completing this lesson, you should be able  to do the following:  "  Describe a view  "  Create, alter the definition of, and drop a view  "  Retrieve data through a view  "  Insert, update, and delete data through  a view  "  Create and use an inline view  "  Perform ³Top-N´ analysis  http://ecomputernotes.com
Database Objects  Object  Description  Basic unit of storage; composed of rows  Table  and columns  View  Logically represents subsets of data from  one or more tables  Sequence  Generates primary key values  Index  Improves the performance of some queries  Synonym  Alternative name for an object  http://ecomputernotes.com
What is a View?  EMPLOYEES   Table:  http://ecomputernotes.com
Why Use Views?  "  To restrict data access  "  To make complex queries easy  "  To provide data independence  "  To present different views of the same data  http://ecomputernotes.com
Simple Views  and Complex Views  Feature  Simple Views   Complex Views  Number of tables  One  One or more  Contain functions  No  Yes  Contain groups of data  No  Yes  DML operations  through  a view  Yes  Not always  http://ecomputernotes.com
Creating a View  "Y ou embed a subquery within the  C REATE VIEW s tatement.  CREATE [OR REPLACE] [FORCE|NOFORCE] VIEW   view  [( alias [,  alias ]...) ]  AS   subquery  [WITH CHECK OPTION [CONSTRAINT   constraint ]] [WITH READ ONLY [CONSTRAINT   constraint ]];  "T he subquery can contain complex  S ELECT  syntax.  http://ecomputernotes.com
Creating a View  "  Create a view,   EMPVU80 , that contains details of employees in department 80.  CREATE VIEW   empvu80  AS SELECT  employee_id, last_name, salary FROM  employees  WHERE  department_id = 80;  View created.  "D escribe the structure of the view by using the  i SQL*Plus   DESCRIBE   command.  DESCRIBE empvu80  http://ecomputernotes.com
Creating a View  "C reate a view by using column aliases in the  subquery.  CREATE VIEW   salvu50  AS SELECT  employee_id ID_NUMBER, last_name NAME, salary*12 ANN_SALARY  FROM  employees  WHERE  department_id = 50;  View created.  "S elect the columns from this view by the given  alias names.  http://ecomputernotes.com
Retrieving Data from a View  SELECT *  FRO M  salvu50;  http://ecomputernotes.com
Querying a View  Oracle Server  i SQL*Plus  USER_VIEWS  SELECT  *  EMPVU80  FROM  empvu80;  SELECT employee_id,  last_name, salary  FROM  employees  WHERE  department_id=80;  EMPLOYEES  http://ecomputernotes.com
Modifying a View  "  Modify the   EMPVU80   view by using   CREATE OR  REPLACE VIEW   clause. Add an alias for each column name.  CREATE OR REPLACE VIEW empvu80  (id_number, name, sal, department_id)  AS SELECT  employee_id, first_name || ' ' || last_name,  salary, department_id  FROM  employees  WHERE  department_id = 80;  View created.  "C olumn aliases in the  C REATE VIEW  clause are  listed in the same order as the columns in the  subquery.  http://ecomputernotes.com
Creating a Complex View  Create a complex view that contains group functions  to display values from two tables.  CREATE VIEW dept_sum_vu  (name, minsal, maxsal, avgsal)  AS SELECT  d.department_name, MIN(e.salary), MAX(e.salary),AVG(e.salary)  FROM  employees e, departments d  WHERE  e.department_id = d.department_id  GROUP BY  d.department_name;  View created.  http://ecomputernotes.com
Rules for Performing  DML Operations on a View  "  You can perform DML operations on simple views.  "  You cannot remove a row if the view contains the  following:  Group functions A   GROUP BY   clause The   DISTINCT   keyword  The pseudocolumn   ROWNUM   keyword  http://ecomputernotes.com
Rules for Performing  DML Operations on a View  You cannot modify data in a view if it contains:  "  Group functions  "  A   GROUP BY   clause  "  The   DISTINCT   keyword  "  The pseudocolumn   ROWNUM   keyword  "  Columns defined by expressions  http://ecomputernotes.com
Rules for Performing  DML Operations on a View  You cannot add data through a view if the view  includes:  "  Group functions  "  A   GROUP BY   clause  "  The   DISTINCT   keyword  "  The pseudocolumn   ROWNUM   keyword  "  Columns defined by expressions  "  NOT NULL   columns in the base tables that are not selected by the view  http://ecomputernotes.com
Using the   WITH CHECK OPTION   Clause  "Y ou can ensure that DML operations performed on  the view stay within the domain of the view by using the   WITH CHECK OPTION   clause.  CREATE OR REPLACE VIEW empvu20  AS SELECT  *  FROM  employees  WHERE  department_id = 20  WITH CHECK OPTION CONSTRAINT empvu20_ck ;  View created.  "A ny attempt to change the department number for  any row in the view fails because it violates the  WITH CHECK OPTION   constraint.  http://ecomputernotes.com
Denying DML Operations  "Y ou can ensure that no DML operations occur by  adding the   WITH READ ONLY   option to your view definition.  "A ny attempt to perform a DML on any row in the  view results in an Oracle server error.  http://ecomputernotes.com
Denying DML Operations  CREATE OR REPLACE VIEW empvu10 (employee_number, employee_name, job_title) AS SELECT  employee_id, last_name, job_id  FROM  employees  WHERE  department_id = 10 WITH READ ONLY;  View created.  http://ecomputernotes.com
Removing a View  You can remove a view without losing data because a view is based on underlying tables in the database.  DROP VIEW   view ;;  DROP VIEW empvu80;  View dropped.  http://ecomputernotes.com
Inline Views  "  An inline view is a subquery with an alias (or  correlation name) that you can use within a SQL  statement.  "  A named subquery in the   FROM   clause of the main  query is an example of an inline view.  "  An inline view is not a schema object.  http://ecomputernotes.com
Top-N Analysis  "T op-N queries ask for the  n   l argest or smallest  values of a column. For example:  What are the ten best selling products?  "  What are the ten worst selling products?  Both largest values and smallest values sets are considered Top-N queries.  http://ecomputernotes.com
Performing Top-N Analysis  The high-level structure of a Top-N analysis query is:  SELECT [ column_list ], ROWNUM FROM  (SELECT [ column_list ] FROM table  ORDER  BY Top-N_column) WHERE  ROWNUM <=  N;  http://ecomputernotes.com
Example of Top-N Analysis  To display the top three earner names and salaries from thefrom the   EMPLOYEES   table:table:  1  2  3  SELECT ROWNUM as RANK, last_name, salary FROM  (SELECT last_name,salary FROM employees ORDER BY salary DESC)  WHERE ROWNUM <= 3;  1  2  3  http://ecomputernotes.com

More Related Content

What's hot (15)

PPTX
Building a Blogging System -- Rapidly using Alpha Five v10 with Codeless AJAX...
Richard Rabins
 
PDF
Web components with Angular
Ana Cidre
 
DOC
Applet
pawan2579
 
PDF
Best Practices for Magento Debugging
varien
 
PDF
Diversified application testing based on a Sylius project
Łukasz Chruściel
 
PPTX
Showroom create flow
Sriparna Biswas
 
PDF
Михаил Крайнюк. Form API: AJAX-commands
DrupalSib
 
PPTX
SPS Stockholm: PowerApps Jumpstart
Sandy Ussia
 
PDF
BDD in practice based on an open source project
Łukasz Chruściel
 
PPT
Oracle Forms- key triggers
Sekhar Byna
 
PDF
What's New in newforms-admin
brosner
 
PDF
Introduction To Angular's reactive forms
Nir Kaufman
 
PPTX
Form Validation in JavaScript
Ravi Bhadauria
 
ODP
Forms With Ajax And Advanced Plugins
Manuel Lemos
 
RTF
Triggers-Sequences-SQL
Patrick Seery
 
Building a Blogging System -- Rapidly using Alpha Five v10 with Codeless AJAX...
Richard Rabins
 
Web components with Angular
Ana Cidre
 
Applet
pawan2579
 
Best Practices for Magento Debugging
varien
 
Diversified application testing based on a Sylius project
Łukasz Chruściel
 
Showroom create flow
Sriparna Biswas
 
Михаил Крайнюк. Form API: AJAX-commands
DrupalSib
 
SPS Stockholm: PowerApps Jumpstart
Sandy Ussia
 
BDD in practice based on an open source project
Łukasz Chruściel
 
Oracle Forms- key triggers
Sekhar Byna
 
What's New in newforms-admin
brosner
 
Introduction To Angular's reactive forms
Nir Kaufman
 
Form Validation in JavaScript
Ravi Bhadauria
 
Forms With Ajax And Advanced Plugins
Manuel Lemos
 
Triggers-Sequences-SQL
Patrick Seery
 

Similar to e computer notes - Creating views (20)

PPT
Les11
Vijay Kumar
 
PPT
Les12
arnold 7490
 
PPT
Creating Views - oracle database
Salman Memon
 
PPT
Les12[1]Creating Views
siavosh kaviani
 
PDF
Database Oracle Basic
Kamlesh Singh
 
PPT
SQL WORKSHOP::Lecture 12
Umair Amjad
 
PPT
Sql views
arshid045
 
PPT
Les10
Sudharsan S
 
PPT
Les11.ppt
AlhassanFederated
 
PPT
Creating other schema objects
Syed Zaid Irshad
 
PPTX
Oracle views
Balqees Al.Mubarak
 
PPT
Oracle view
Madhavendra Dutt
 
PDF
Lesson10
renguzi
 
PPT
Views
Rahul Gupta
 
PPT
Module05
Sridhar P
 
PPTX
Designing and Creating Views, Inline Functions, and Synonyms
Tayba Farooqui
 
PDF
Sql ch 13 - sql-views
Mukesh Tekwani
 
PPT
chap 9 dbms.ppt
arjun431527
 
Creating Views - oracle database
Salman Memon
 
Les12[1]Creating Views
siavosh kaviani
 
Database Oracle Basic
Kamlesh Singh
 
SQL WORKSHOP::Lecture 12
Umair Amjad
 
Sql views
arshid045
 
Creating other schema objects
Syed Zaid Irshad
 
Oracle views
Balqees Al.Mubarak
 
Oracle view
Madhavendra Dutt
 
Lesson10
renguzi
 
Module05
Sridhar P
 
Designing and Creating Views, Inline Functions, and Synonyms
Tayba Farooqui
 
Sql ch 13 - sql-views
Mukesh Tekwani
 
chap 9 dbms.ppt
arjun431527
 
Ad

More from ecomputernotes (20)

PPT
computer notes - Data Structures - 30
ecomputernotes
 
PPT
computer notes - Data Structures - 39
ecomputernotes
 
PPT
computer notes - Data Structures - 11
ecomputernotes
 
PPT
computer notes - Data Structures - 20
ecomputernotes
 
PPT
computer notes - Data Structures - 15
ecomputernotes
 
DOC
Computer notes - Including Constraints
ecomputernotes
 
DOC
Computer notes - Date time Functions
ecomputernotes
 
DOC
Computer notes - Subqueries
ecomputernotes
 
DOC
Computer notes - Other Database Objects
ecomputernotes
 
PPT
computer notes - Data Structures - 28
ecomputernotes
 
PPT
computer notes - Data Structures - 19
ecomputernotes
 
PPT
computer notes - Data Structures - 31
ecomputernotes
 
PPT
computer notes - Data Structures - 4
ecomputernotes
 
PPT
computer notes - Data Structures - 13
ecomputernotes
 
DOC
Computer notes - Advanced Subqueries
ecomputernotes
 
DOC
Computer notes - Aggregating Data Using Group Functions
ecomputernotes
 
PPT
computer notes - Data Structures - 16
ecomputernotes
 
PPT
computer notes - Data Structures - 22
ecomputernotes
 
PPT
computer notes - Data Structures - 35
ecomputernotes
 
PPT
computer notes - Data Structures - 36
ecomputernotes
 
computer notes - Data Structures - 30
ecomputernotes
 
computer notes - Data Structures - 39
ecomputernotes
 
computer notes - Data Structures - 11
ecomputernotes
 
computer notes - Data Structures - 20
ecomputernotes
 
computer notes - Data Structures - 15
ecomputernotes
 
Computer notes - Including Constraints
ecomputernotes
 
Computer notes - Date time Functions
ecomputernotes
 
Computer notes - Subqueries
ecomputernotes
 
Computer notes - Other Database Objects
ecomputernotes
 
computer notes - Data Structures - 28
ecomputernotes
 
computer notes - Data Structures - 19
ecomputernotes
 
computer notes - Data Structures - 31
ecomputernotes
 
computer notes - Data Structures - 4
ecomputernotes
 
computer notes - Data Structures - 13
ecomputernotes
 
Computer notes - Advanced Subqueries
ecomputernotes
 
Computer notes - Aggregating Data Using Group Functions
ecomputernotes
 
computer notes - Data Structures - 16
ecomputernotes
 
computer notes - Data Structures - 22
ecomputernotes
 
computer notes - Data Structures - 35
ecomputernotes
 
computer notes - Data Structures - 36
ecomputernotes
 
Ad

Recently uploaded (20)

PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 

e computer notes - Creating views

  • 1. Creating Views http://ecomputernotes.com
  • 2. Objectives After completing this lesson, you should be able to do the following: &quot; Describe a view &quot; Create, alter the definition of, and drop a view &quot; Retrieve data through a view &quot; Insert, update, and delete data through a view &quot; Create and use an inline view &quot; Perform ³Top-N´ analysis http://ecomputernotes.com
  • 3. Database Objects Object Description Basic unit of storage; composed of rows Table and columns View Logically represents subsets of data from one or more tables Sequence Generates primary key values Index Improves the performance of some queries Synonym Alternative name for an object http://ecomputernotes.com
  • 4. What is a View? EMPLOYEES Table: http://ecomputernotes.com
  • 5. Why Use Views? &quot; To restrict data access &quot; To make complex queries easy &quot; To provide data independence &quot; To present different views of the same data http://ecomputernotes.com
  • 6. Simple Views and Complex Views Feature Simple Views Complex Views Number of tables One One or more Contain functions No Yes Contain groups of data No Yes DML operations through a view Yes Not always http://ecomputernotes.com
  • 7. Creating a View &quot;Y ou embed a subquery within the C REATE VIEW s tatement. CREATE [OR REPLACE] [FORCE|NOFORCE] VIEW view [( alias [, alias ]...) ] AS subquery [WITH CHECK OPTION [CONSTRAINT constraint ]] [WITH READ ONLY [CONSTRAINT constraint ]]; &quot;T he subquery can contain complex S ELECT syntax. http://ecomputernotes.com
  • 8. Creating a View &quot; Create a view, EMPVU80 , that contains details of employees in department 80. CREATE VIEW empvu80 AS SELECT employee_id, last_name, salary FROM employees WHERE department_id = 80; View created. &quot;D escribe the structure of the view by using the i SQL*Plus DESCRIBE command. DESCRIBE empvu80 http://ecomputernotes.com
  • 9. Creating a View &quot;C reate a view by using column aliases in the subquery. CREATE VIEW salvu50 AS SELECT employee_id ID_NUMBER, last_name NAME, salary*12 ANN_SALARY FROM employees WHERE department_id = 50; View created. &quot;S elect the columns from this view by the given alias names. http://ecomputernotes.com
  • 10. Retrieving Data from a View SELECT * FRO M salvu50; http://ecomputernotes.com
  • 11. Querying a View Oracle Server i SQL*Plus USER_VIEWS SELECT * EMPVU80 FROM empvu80; SELECT employee_id, last_name, salary FROM employees WHERE department_id=80; EMPLOYEES http://ecomputernotes.com
  • 12. Modifying a View &quot; Modify the EMPVU80 view by using CREATE OR REPLACE VIEW clause. Add an alias for each column name. CREATE OR REPLACE VIEW empvu80 (id_number, name, sal, department_id) AS SELECT employee_id, first_name || ' ' || last_name, salary, department_id FROM employees WHERE department_id = 80; View created. &quot;C olumn aliases in the C REATE VIEW clause are listed in the same order as the columns in the subquery. http://ecomputernotes.com
  • 13. Creating a Complex View Create a complex view that contains group functions to display values from two tables. CREATE VIEW dept_sum_vu (name, minsal, maxsal, avgsal) AS SELECT d.department_name, MIN(e.salary), MAX(e.salary),AVG(e.salary) FROM employees e, departments d WHERE e.department_id = d.department_id GROUP BY d.department_name; View created. http://ecomputernotes.com
  • 14. Rules for Performing DML Operations on a View &quot; You can perform DML operations on simple views. &quot; You cannot remove a row if the view contains the following: Group functions A GROUP BY clause The DISTINCT keyword The pseudocolumn ROWNUM keyword http://ecomputernotes.com
  • 15. Rules for Performing DML Operations on a View You cannot modify data in a view if it contains: &quot; Group functions &quot; A GROUP BY clause &quot; The DISTINCT keyword &quot; The pseudocolumn ROWNUM keyword &quot; Columns defined by expressions http://ecomputernotes.com
  • 16. Rules for Performing DML Operations on a View You cannot add data through a view if the view includes: &quot; Group functions &quot; A GROUP BY clause &quot; The DISTINCT keyword &quot; The pseudocolumn ROWNUM keyword &quot; Columns defined by expressions &quot; NOT NULL columns in the base tables that are not selected by the view http://ecomputernotes.com
  • 17. Using the WITH CHECK OPTION Clause &quot;Y ou can ensure that DML operations performed on the view stay within the domain of the view by using the WITH CHECK OPTION clause. CREATE OR REPLACE VIEW empvu20 AS SELECT * FROM employees WHERE department_id = 20 WITH CHECK OPTION CONSTRAINT empvu20_ck ; View created. &quot;A ny attempt to change the department number for any row in the view fails because it violates the WITH CHECK OPTION constraint. http://ecomputernotes.com
  • 18. Denying DML Operations &quot;Y ou can ensure that no DML operations occur by adding the WITH READ ONLY option to your view definition. &quot;A ny attempt to perform a DML on any row in the view results in an Oracle server error. http://ecomputernotes.com
  • 19. Denying DML Operations CREATE OR REPLACE VIEW empvu10 (employee_number, employee_name, job_title) AS SELECT employee_id, last_name, job_id FROM employees WHERE department_id = 10 WITH READ ONLY; View created. http://ecomputernotes.com
  • 20. Removing a View You can remove a view without losing data because a view is based on underlying tables in the database. DROP VIEW view ;; DROP VIEW empvu80; View dropped. http://ecomputernotes.com
  • 21. Inline Views &quot; An inline view is a subquery with an alias (or correlation name) that you can use within a SQL statement. &quot; A named subquery in the FROM clause of the main query is an example of an inline view. &quot; An inline view is not a schema object. http://ecomputernotes.com
  • 22. Top-N Analysis &quot;T op-N queries ask for the n l argest or smallest values of a column. For example: What are the ten best selling products? &quot; What are the ten worst selling products? Both largest values and smallest values sets are considered Top-N queries. http://ecomputernotes.com
  • 23. Performing Top-N Analysis The high-level structure of a Top-N analysis query is: SELECT [ column_list ], ROWNUM FROM (SELECT [ column_list ] FROM table ORDER BY Top-N_column) WHERE ROWNUM <= N; http://ecomputernotes.com
  • 24. Example of Top-N Analysis To display the top three earner names and salaries from thefrom the EMPLOYEES table:table: 1 2 3 SELECT ROWNUM as RANK, last_name, salary FROM (SELECT last_name,salary FROM employees ORDER BY salary DESC) WHERE ROWNUM <= 3; 1 2 3 http://ecomputernotes.com