SlideShare une entreprise Scribd logo
1  sur  30
Oracle9 i  Extensions to  DML and DDL Statements
Objectives ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Review of the  INSERT  Statement ,[object Object],[object Object],INSERT INTO table  [( column  [ , column... ])] VALUES (value  [ , value... ]); INSERT INTO departments(department_id, department_name,  manager_id, location_id) VALUES  (70, 'Public Relations', 100, 1700); 1 row created.
Review of the  UPDATE  Statement ,[object Object],[object Object],[object Object],UPDATE table SET column  =  value  [,  column  =  value, ... ] [WHERE  condition ]; UPDATE employees SET  department_id = 70 WHERE  employee_id = 142; 1 row updated.
Overview of Multitable  INSERT  Statements ,[object Object],[object Object],[object Object],[object Object],[object Object]
Hidden Slide
Types of Multitable  INSERT  Statements ,[object Object],[object Object],[object Object],[object Object],[object Object]
Multitable  INSERT  Statements INSERT [ALL] [conditional_insert_clause] [insert_into_clause values_clause] (subquery) [ALL] [FIRST] [WHEN condition THEN] [insert_into_clause values_clause] [ELSE] [insert_into_clause values_clause]  conditional_insert_clause Syntax
Hidden Slide
Unconditional  INSERT ALL ,[object Object],[object Object],INSERT  ALL   INTO sal_history VALUES(EMPID,HIREDATE,SAL)   INTO mgr_history VALUES(EMPID,MGR,SAL) SELECT employee_id EMPID, hire_date HIREDATE,    salary SAL, manager_id MGR  FROM  employees   WHERE employee_id > 200; 8 rows created.
Conditional  INSERT ALL ,[object Object],[object Object],[object Object]
Conditional  INSERT ALL INSERT ALL   WHEN SAL > 10000 THEN   INTO sal_history VALUES(EMPID,HIREDATE,SAL)   WHEN MGR > 200  THEN    INTO mgr_history VALUES(EMPID,MGR,SAL)  SELECT employee_id EMPID,hire_date HIREDATE,  salary SAL, manager_id MGR  FROM  employees   WHERE  employee_id > 200; 4 rows created.
Conditional  FIRST INSERT ,[object Object],[object Object],[object Object],[object Object]
Conditional  FIRST INSERT INSERT FIRST   WHEN SAL  > 25000  THEN   INTO special_sal VALUES(DEPTID, SAL)   WHEN HIREDATE like ('%00%') THEN   INTO hiredate_history_00 VALUES(DEPTID,HIREDATE)   WHEN HIREDATE like ('%99%') THEN   INTO hiredate_history_99 VALUES(DEPTID, HIREDATE)   ELSE   INTO hiredate_history VALUES(DEPTID, HIREDATE) SELECT department_id DEPTID, SUM(salary) SAL,   MAX(hire_date) HIREDATE   FROM  employees GROUP BY department_id; 8 rows created.
Pivoting  INSERT ,[object Object],[object Object],[object Object],[object Object],[object Object]
Pivoting  INSERT INSERT ALL   INTO sales_info VALUES (employee_id,week_id,sales_MON)   INTO sales_info VALUES (employee_id,week_id,sales_TUE)   INTO sales_info VALUES (employee_id,week_id,sales_WED)   INTO sales_info VALUES (employee_id,week_id,sales_THUR)   INTO sales_info VALUES (employee_id,week_id, sales_FRI)   SELECT EMPLOYEE_ID, week_id, sales_MON, sales_TUE,   sales_WED, sales_THUR,sales_FRI    FROM sales_source_data; 5 rows created.
Hidden Slide
External Tables ,[object Object],[object Object],[object Object],[object Object]
Creating an External Table ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example of Creating an External Table ,[object Object],CREATE DIRECTORY emp_dir AS '/flat_files' ;
Example of Creating an External Table CREATE TABLE oldemp (    empno NUMBER, empname CHAR(20), birthdate DATE)   ORGANIZATION EXTERNAL   (TYPE ORACLE_LOADER   DEFAULT DIRECTORY emp_dir   ACCESS PARAMETERS   (RECORDS DELIMITED BY NEWLINE   BADFILE 'bad_emp'    LOGFILE 'log_emp'    FIELDS TERMINATED BY ','    (empno CHAR,   empname CHAR,   birthdate CHAR date_format date mask "dd-mon-yyyy"))   LOCATION ('emp1.txt'))   PARALLEL 5   REJECT LIMIT 200; Table created.
Hidden Slide
Querying External Tables SELECT  *  FROM oldemp emp1.txt
CREATE INDEX  with  CREATE TABLE  Statement   CREATE TABLE NEW_EMP (employee_id NUMBER(6)   PRIMARY KEY USING INDEX   (CREATE INDEX emp_id_idx ON   NEW_EMP(employee_id)), first_name  VARCHAR2(20), last_name  VARCHAR2(25)); Table created. SELECT INDEX_NAME, TABLE_NAME  FROM  USER_INDEXES WHERE  TABLE_NAME = 'NEW_EMP';
Summary ,[object Object],[object Object],[object Object],[object Object]
Practice 20 Overview ,[object Object],[object Object],[object Object],[object Object],[object Object]
Hidden Slide
Hidden Slide
Hidden Slide
Hidden Slide

Contenu connexe

Tendances

Tendances (20)

Entity Attribute Value (Eav)
Entity   Attribute   Value (Eav)Entity   Attribute   Value (Eav)
Entity Attribute Value (Eav)
 
MY SQL
MY SQLMY SQL
MY SQL
 
Query
QueryQuery
Query
 
SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables  SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables
 
EAV Sytem- Magento EAV Model
EAV Sytem- Magento EAV ModelEAV Sytem- Magento EAV Model
EAV Sytem- Magento EAV Model
 
vFabric SQLFire Introduction
vFabric SQLFire IntroductionvFabric SQLFire Introduction
vFabric SQLFire Introduction
 
MULTIPLE TABLES
MULTIPLE TABLES MULTIPLE TABLES
MULTIPLE TABLES
 
Oracle: Basic SQL
Oracle: Basic SQLOracle: Basic SQL
Oracle: Basic SQL
 
Implementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord modelsImplementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord models
 
Les18
Les18Les18
Les18
 
Interacting with Oracle Database
Interacting with Oracle DatabaseInteracting with Oracle Database
Interacting with Oracle Database
 
Sql fundamentals group by part2
Sql fundamentals   group by part2Sql fundamentals   group by part2
Sql fundamentals group by part2
 
Sql Tags
Sql TagsSql Tags
Sql Tags
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
Exportrows
ExportrowsExportrows
Exportrows
 
Sql basics
Sql  basicsSql  basics
Sql basics
 
Sql
SqlSql
Sql
 
Les17
Les17Les17
Les17
 
Mocks Enabling Test-Driven Design
Mocks Enabling Test-Driven DesignMocks Enabling Test-Driven Design
Mocks Enabling Test-Driven Design
 
Advanced Sql Training
Advanced Sql TrainingAdvanced Sql Training
Advanced Sql Training
 

Similaire à Les20

Similaire à Les20 (20)

Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
 
DOODB_LAB.pptx
DOODB_LAB.pptxDOODB_LAB.pptx
DOODB_LAB.pptx
 
Oracle - Program with PL/SQL - Lession 09
Oracle - Program with PL/SQL - Lession 09Oracle - Program with PL/SQL - Lession 09
Oracle - Program with PL/SQL - Lession 09
 
Oracle - Program with PL/SQL - Lession 03
Oracle - Program with PL/SQL - Lession 03Oracle - Program with PL/SQL - Lession 03
Oracle - Program with PL/SQL - Lession 03
 
Les08 (manipulating data)
Les08 (manipulating data)Les08 (manipulating data)
Les08 (manipulating data)
 
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)
 
Les08
Les08Les08
Les08
 
Les06
Les06Les06
Les06
 
Oracle tips and tricks
Oracle tips and tricksOracle tips and tricks
Oracle tips and tricks
 
Basic SQL Statments
Basic SQL StatmentsBasic SQL Statments
Basic SQL Statments
 
Les09
Les09Les09
Les09
 
Aggregate Functions,Final
Aggregate Functions,FinalAggregate Functions,Final
Aggregate Functions,Final
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
SQL -PHP Tutorial
SQL -PHP TutorialSQL -PHP Tutorial
SQL -PHP Tutorial
 
chap 7.ppt(sql).ppt
chap 7.ppt(sql).pptchap 7.ppt(sql).ppt
chap 7.ppt(sql).ppt
 
My Sql concepts
My Sql conceptsMy Sql concepts
My Sql concepts
 
SQL
SQLSQL
SQL
 
Oracle: Functions
Oracle: FunctionsOracle: Functions
Oracle: Functions
 
Oracle: Functions
Oracle: FunctionsOracle: Functions
Oracle: Functions
 
Sql 2006
Sql 2006Sql 2006
Sql 2006
 

Plus de Vijay Kumar (15)

Les19
Les19Les19
Les19
 
Les15
Les15Les15
Les15
 
Les16
Les16Les16
Les16
 
Les14
Les14Les14
Les14
 
Les13
Les13Les13
Les13
 
Les12
Les12Les12
Les12
 
Les10
Les10Les10
Les10
 
Les11
Les11Les11
Les11
 
Les07
Les07Les07
Les07
 
Les09
Les09Les09
Les09
 
Les06
Les06Les06
Les06
 
Les05
Les05Les05
Les05
 
Les04
Les04Les04
Les04
 
Les03
Les03Les03
Les03
 
Les02
Les02Les02
Les02
 

Dernier

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 

Dernier (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 

Les20

  • 1. Oracle9 i Extensions to DML and DDL Statements
  • 2.
  • 3.
  • 4.
  • 5.
  • 7.
  • 8. Multitable INSERT Statements INSERT [ALL] [conditional_insert_clause] [insert_into_clause values_clause] (subquery) [ALL] [FIRST] [WHEN condition THEN] [insert_into_clause values_clause] [ELSE] [insert_into_clause values_clause] conditional_insert_clause Syntax
  • 10.
  • 11.
  • 12. Conditional INSERT ALL INSERT ALL WHEN SAL > 10000 THEN INTO sal_history VALUES(EMPID,HIREDATE,SAL) WHEN MGR > 200 THEN INTO mgr_history VALUES(EMPID,MGR,SAL) SELECT employee_id EMPID,hire_date HIREDATE, salary SAL, manager_id MGR FROM employees WHERE employee_id > 200; 4 rows created.
  • 13.
  • 14. Conditional FIRST INSERT INSERT FIRST WHEN SAL > 25000 THEN INTO special_sal VALUES(DEPTID, SAL) WHEN HIREDATE like ('%00%') THEN INTO hiredate_history_00 VALUES(DEPTID,HIREDATE) WHEN HIREDATE like ('%99%') THEN INTO hiredate_history_99 VALUES(DEPTID, HIREDATE) ELSE INTO hiredate_history VALUES(DEPTID, HIREDATE) SELECT department_id DEPTID, SUM(salary) SAL, MAX(hire_date) HIREDATE FROM employees GROUP BY department_id; 8 rows created.
  • 15.
  • 16. Pivoting INSERT INSERT ALL INTO sales_info VALUES (employee_id,week_id,sales_MON) INTO sales_info VALUES (employee_id,week_id,sales_TUE) INTO sales_info VALUES (employee_id,week_id,sales_WED) INTO sales_info VALUES (employee_id,week_id,sales_THUR) INTO sales_info VALUES (employee_id,week_id, sales_FRI) SELECT EMPLOYEE_ID, week_id, sales_MON, sales_TUE, sales_WED, sales_THUR,sales_FRI FROM sales_source_data; 5 rows created.
  • 18.
  • 19.
  • 20.
  • 21. Example of Creating an External Table CREATE TABLE oldemp ( empno NUMBER, empname CHAR(20), birthdate DATE) ORGANIZATION EXTERNAL (TYPE ORACLE_LOADER DEFAULT DIRECTORY emp_dir ACCESS PARAMETERS (RECORDS DELIMITED BY NEWLINE BADFILE 'bad_emp' LOGFILE 'log_emp' FIELDS TERMINATED BY ',' (empno CHAR, empname CHAR, birthdate CHAR date_format date mask "dd-mon-yyyy")) LOCATION ('emp1.txt')) PARALLEL 5 REJECT LIMIT 200; Table created.
  • 23. Querying External Tables SELECT * FROM oldemp emp1.txt
  • 24. CREATE INDEX with CREATE TABLE Statement CREATE TABLE NEW_EMP (employee_id NUMBER(6) PRIMARY KEY USING INDEX (CREATE INDEX emp_id_idx ON NEW_EMP(employee_id)), first_name VARCHAR2(20), last_name VARCHAR2(25)); Table created. SELECT INDEX_NAME, TABLE_NAME FROM USER_INDEXES WHERE TABLE_NAME = 'NEW_EMP';
  • 25.
  • 26.

Notes de l'éditeur

  1. Schedule: Timing Topic 40 minutes Lecture 30 minutes Practice 70 minutes Total