SlideShare a Scribd company logo
Creating Views
Objectives ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Database Objects Description Basic unit of storage; composed of rows  and columns Logically represents subsets of data from  one or more tables Generates primary key values Improves the performance of some queries Alternative name for an object Object Table View Sequence Index Synonym
What is a View? EMPLOYEES  Table:
Why Use Views? ,[object Object],[object Object],[object Object],[object Object]
Simple Views  and Complex Views ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Creating a View ,[object Object],[object Object],CREATE [OR REPLACE] [FORCE| NOFORCE ] VIEW  view [( alias [,  alias ]...)] AS  subquery [WITH CHECK OPTION [CONSTRAINT  constraint ]] [WITH READ ONLY [CONSTRAINT  constraint ]];
Creating a View ,[object Object],[object Object],DESCRIBE empvu80 CREATE VIEW  empvu80 AS SELECT  employee_id, last_name, salary FROM  employees WHERE  department_id = 80; View created.
Creating a View ,[object Object],[object Object],CREATE VIEW  salvu50 AS SELECT  employee_id ID_NUMBER, last_name NAME, salary*12 ANN_SALARY FROM  employees WHERE  department_id = 50; View created.
Retrieving Data from a View SELECT * FROM salvu50;
Querying a View i SQL*Plus SELECT  * FROM  empvu80 ; Oracle Server USER_VIEWS   EMPVU80 SELECT employee_id,  last_name, salary FROM  employees WHERE  department_id=80; EMPLOYEES
Modifying a View ,[object Object],[object Object],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.
Creating a Complex View ,[object Object],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.
Rules for Performing  DML Operations on a View ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Rules for Performing  DML Operations on a View ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Rules for Performing  DML Operations on a View ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],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.
Denying DML Operations ,[object Object],[object Object]
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.
Removing a View ,[object Object],DROP VIEW empvu80; View dropped. DROP VIEW  view ;
Inline Views ,[object Object],[object Object],[object Object]
Top-N Analysis ,[object Object],[object Object],[object Object],[object Object]
Performing Top-N Analysis ,[object Object],SELECT [ column_list ], ROWNUM  FROM  (SELECT [ column_list ]  FROM table ORDER  BY Top-N_column) WHERE  ROWNUM <=  N;
Example of Top-N Analysis ,[object Object],SELECT ROWNUM as RANK, last_name, salary  FROM  (SELECT last_name,salary FROM employees ORDER BY salary DESC) WHERE ROWNUM <= 3; 3 1 2 1 2 3
Summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Practice 11 Overview ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
 
 

More Related Content

What's hot

SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functions
Vikas Gupta
 
Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)
Achmad Solichin
 
Retrieving data using the sql select statement
Retrieving data using the sql select statementRetrieving data using the sql select statement
Retrieving data using the sql select statement
Syed Zaid Irshad
 

What's hot (19)

Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)
 
Les17
Les17Les17
Les17
 
Oracle: Functions
Oracle: FunctionsOracle: Functions
Oracle: Functions
 
Excell vba
Excell vbaExcell vba
Excell vba
 
Introduction to oracle functions
Introduction to oracle functionsIntroduction to oracle functions
Introduction to oracle functions
 
Database Systems - SQL - DDL Statements (Chapter 3/3)
Database Systems - SQL - DDL Statements (Chapter 3/3)Database Systems - SQL - DDL Statements (Chapter 3/3)
Database Systems - SQL - DDL Statements (Chapter 3/3)
 
View
ViewView
View
 
Les10
Les10Les10
Les10
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functions
 
Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)
 
Nested Queries Lecture
Nested Queries LectureNested Queries Lecture
Nested Queries Lecture
 
Updat Dir
Updat DirUpdat Dir
Updat Dir
 
1. dml select statement reterive data
1. dml select statement reterive data1. dml select statement reterive data
1. dml select statement reterive data
 
Les07
Les07Les07
Les07
 
Oracle - Program with PL/SQL - Lession 10
Oracle - Program with PL/SQL - Lession 10Oracle - Program with PL/SQL - Lession 10
Oracle - Program with PL/SQL - Lession 10
 
Lab1 select statement
Lab1 select statementLab1 select statement
Lab1 select statement
 
Creating Views - oracle database
Creating Views - oracle databaseCreating Views - oracle database
Creating Views - oracle database
 
Les02
Les02Les02
Les02
 
Retrieving data using the sql select statement
Retrieving data using the sql select statementRetrieving data using the sql select statement
Retrieving data using the sql select statement
 

Similar to Les11

e computer notes - Creating views
e computer notes - Creating viewse computer notes - Creating views
e computer notes - Creating views
ecomputernotes
 
Sql server ___________session_16(views)
Sql server  ___________session_16(views)Sql server  ___________session_16(views)
Sql server ___________session_16(views)
Ehtisham Ali
 
Lesson10
Lesson10Lesson10
Lesson10
renguzi
 
Subqueries views stored procedures_triggers_transactions
Subqueries views stored procedures_triggers_transactionsSubqueries views stored procedures_triggers_transactions
Subqueries views stored procedures_triggers_transactions
maxpane
 

Similar to Les11 (20)

Les10
Les10Les10
Les10
 
e computer notes - Creating views
e computer notes - Creating viewse computer notes - Creating views
e computer notes - Creating views
 
Designing and Creating Views, Inline Functions, and Synonyms
 Designing and Creating Views, Inline Functions, and Synonyms Designing and Creating Views, Inline Functions, and Synonyms
Designing and Creating Views, Inline Functions, and Synonyms
 
Chapter 07 ddl_sql
Chapter 07 ddl_sqlChapter 07 ddl_sql
Chapter 07 ddl_sql
 
Module05
Module05Module05
Module05
 
Les11.ppt
Les11.pptLes11.ppt
Les11.ppt
 
View
ViewView
View
 
Sql views
Sql viewsSql views
Sql views
 
Sql ch 13 - sql-views
Sql ch 13 - sql-viewsSql ch 13 - sql-views
Sql ch 13 - sql-views
 
Sql server ___________session_16(views)
Sql server  ___________session_16(views)Sql server  ___________session_16(views)
Sql server ___________session_16(views)
 
Sql viwes
Sql viwesSql viwes
Sql viwes
 
View
ViewView
View
 
01 basic orders
01   basic orders01   basic orders
01 basic orders
 
View
ViewView
View
 
Lec9_Lab_CSC371_Database Systems course.pptx
Lec9_Lab_CSC371_Database Systems course.pptxLec9_Lab_CSC371_Database Systems course.pptx
Lec9_Lab_CSC371_Database Systems course.pptx
 
Les12
Les12Les12
Les12
 
Oracle view
Oracle viewOracle view
Oracle view
 
Lesson10
Lesson10Lesson10
Lesson10
 
Chap 7
Chap 7Chap 7
Chap 7
 
Subqueries views stored procedures_triggers_transactions
Subqueries views stored procedures_triggers_transactionsSubqueries views stored procedures_triggers_transactions
Subqueries views stored procedures_triggers_transactions
 

More from Vijay Kumar (14)

Les20
Les20Les20
Les20
 
Les19
Les19Les19
Les19
 
Les15
Les15Les15
Les15
 
Les16
Les16Les16
Les16
 
Les14
Les14Les14
Les14
 
Les13
Les13Les13
Les13
 
Les12
Les12Les12
Les12
 
Les09
Les09Les09
Les09
 
Les08
Les08Les08
Les08
 
Les06
Les06Les06
Les06
 
Les05
Les05Les05
Les05
 
Les04
Les04Les04
Les04
 
Les03
Les03Les03
Les03
 
Les02
Les02Les02
Les02
 

Recently uploaded

Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Peter Udo Diehl
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 

Recently uploaded (20)

Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya HalderCustom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
Custom Approval Process: A New Perspective, Pavel Hrbacek & Anindya Halder
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Agentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdfAgentic RAG What it is its types applications and implementation.pdf
Agentic RAG What it is its types applications and implementation.pdf
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 

Les11

  • 2.
  • 3. Database Objects Description Basic unit of storage; composed of rows and columns Logically represents subsets of data from one or more tables Generates primary key values Improves the performance of some queries Alternative name for an object Object Table View Sequence Index Synonym
  • 4. What is a View? EMPLOYEES Table:
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10. Retrieving Data from a View SELECT * FROM salvu50;
  • 11. Querying a View i SQL*Plus SELECT * FROM empvu80 ; Oracle Server USER_VIEWS EMPVU80 SELECT employee_id, last_name, salary FROM employees WHERE department_id=80; EMPLOYEES
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 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.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.  
  • 28.  

Editor's Notes

  1. Schedule: Timing Topic 20 minutes Lecture 20 minutes Practice 40 minutes Total