SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (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
 

Ähnlich wie Les20

Ähnlich wie 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
 

Mehr von 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
 

Kürzlich hochgeladen

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Kürzlich hochgeladen (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

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.

Hinweis der Redaktion

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