SlideShare une entreprise Scribd logo
1  sur  28
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]
 
 

Contenu connexe

Tendances

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
 

Tendances (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
 

Similaire à 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
 

Similaire à 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
 
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
 
chap 7.ppt(sql).ppt
chap 7.ppt(sql).pptchap 7.ppt(sql).ppt
chap 7.ppt(sql).ppt
 

Plus de 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
 

Dernier

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
Safe Software
 
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
Safe Software
 

Dernier (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
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...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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
 
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
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

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.  

Notes de l'éditeur

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