Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Opérateurs Ensemblistes | SQL Oracle

1,445 views

Published on

Opérateurs Ensemblistes | SQL Oracle. Telecharger Cours sql oracle gratuit, administration oracle,A la fin de ce chapitre, vous saurez :
Décrire les opérateurs ensemblistes
Utiliser un opérateur ensembliste pour combiner plusieurs requêtes en une seule
Vérifier l'ordre des lignes ramenées

Published in: Education
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THAT BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download Full doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download PDF EBOOK here { http://bit.ly/2m77EgH } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... Download doc Ebook here { http://bit.ly/2m77EgH } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book that can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer that is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story That Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money That the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths that Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Opérateurs Ensemblistes | SQL Oracle

  1. 1. Copyright © Oracle Corporation, 1998. Tous droits réservés. 66 Opérateurs Ensemblistes www.TelechargerCours.com
  2. 2. 6-2 Copyright © Oracle Corporation, 1998. Tous droits réservés. Objectifs A la fin de ce chapitre, vous saurez :A la fin de ce chapitre, vous saurez : • Décrire les opérateurs ensemblistes • Utiliser un opérateur ensembliste pour combiner plusieurs requêtes en une seule • Vérifier l'ordre des lignes ramenées www.TelechargerCours.com
  3. 3. 6-3 Copyright © Oracle Corporation, 1998. Tous droits réservés. IntersectIntersect AA BB AA BB UnionUnion / Union All/ Union All AA BB AA BB MinusMinus Opérateurs Ensemblistes www.TelechargerCours.com
  4. 4. 6-4 Copyright © Oracle Corporation, 1998. Tous droits réservés. Tables Utilisées dans ce Chapitre EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO --------- ---------- --------- --------- --------- --------- --------- --------- 7839 KING PRESIDENT 17-NOV-81 5000 10 7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 7782 CLARK MANAGER 7839 09-JUN-81 1500 10 7566 JONES MANAGER 7839 02-APR-81 2975 20 7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30 7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30 7900 JAMES CLERK 7698 03-DEC-81 950 30 7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30 7902 FORD ANALYST 7566 03-DEC-81 3000 20 7369 SMITH CLERK 7902 17-DEC-80 800 20 7788 SCOTT ANALYST 7566 09-DEC-82 3000 20 7876 ADAMS CLERK 7788 12-JAN-83 1100 20 7934 MILLER CLERK 7782 23-JAN-82 1300 10 EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO --------- ---------- --------- --------- --------- --------- --------- --------- 7839 KING PRESIDENT 17-NOV-81 5000 10 7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 7782 CLARK MANAGER 7839 09-JUN-81 1500 10 7566 JONES MANAGER 7839 02-APR-81 2975 20 7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30 7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30 7900 JAMES CLERK 7698 03-DEC-81 950 30 7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30 7902 FORD ANALYST 7566 03-DEC-81 3000 20 7369 SMITH CLERK 7902 17-DEC-80 800 20 7788 SCOTT ANALYST 7566 09-DEC-82 3000 20 7876 ADAMS CLERK 7788 12-JAN-83 1100 20 7934 MILLER CLERK 7782 23-JAN-82 1300 10 EMPEMP EMP_HISTORYEMP_HISTORY EMPID NAME TITLE DATE_OUT DEPTID --------- -------------------- --------- --------- --------- 6087 SPENCER OPERATOR 27-NOV-81 20 6185 VANDYKE MANAGER 17-JAN-81 10 6235 BALFORD CLERK 22-FEB-80 20 7788 SCOTT ANALYST 05-MAY-81 20 7001 JEWELL ANALYST 10-JUN-81 30 7499 ALLEN SALESMAN 01-AUG-80 20 7225 BRIGGS PAY CLERK 27-NOV-81 10 7782 CLARK MANAGER 12-FEB-80 10 7356 WILD DIRECTOR 01-NOV-81 10 EMPID NAME TITLE DATE_OUT DEPTID --------- -------------------- --------- --------- --------- 6087 SPENCER OPERATOR 27-NOV-81 20 6185 VANDYKE MANAGER 17-JAN-81 10 6235 BALFORD CLERK 22-FEB-80 20 7788 SCOTT ANALYST 05-MAY-81 20 7001 JEWELL ANALYST 10-JUN-81 30 7499 ALLEN SALESMAN 01-AUG-80 20 7225 BRIGGS PAY CLERK 27-NOV-81 10 7782 CLARK MANAGER 12-FEB-80 10 7356 WILD DIRECTOR 01-NOV-81 10 www.TelechargerCours.com
  5. 5. 6-5 Copyright © Oracle Corporation, 1998. Tous droits réservés. UNION AA BB www.TelechargerCours.com
  6. 6. 6-6 Copyright © Oracle Corporation, 1998. Tous droits réservés. Utilisation de l'Opérateur UNION Affichez le nom, le poste et le départementAffichez le nom, le poste et le département de tous les employés.de tous les employés. ENAME JOB DEPTNO ---------- --------- --------- ADAMS CLERK 30 ALLEN SALESMAN 30 ALLEN SALESMAN 20 BALFORD CLERK 20 BLAKE MANAGER 30 ... 20 rows selected. SQL> SELECT ename, job, deptno 2 FROM emp 3 UNION 4 SELECT name, title, deptid 5 FROM emp_history; www.TelechargerCours.com
  7. 7. 6-7 Copyright © Oracle Corporation, 1998. Tous droits réservés. Utilisation de l'Opérateur UNION Affichez le nom, le poste et le départementAffichez le nom, le poste et le département et le salaire de tous les employés.et le salaire de tous les employés. ENAME JOB DEPTNO SAL ---------- --------- --------- --------- ADAMS CLERK 30 1100 ALLEN SALESMAN 30 0 ALLEN SALESMAN 20 1600 BALFORD CLERK 20 0 BLAKE MANAGER 30 ... 20 rows selected. SQL> SELECT ename, job, deptno,sal 2 FROM emp 3 UNION 4 SELECT name, title, deptid,0 5 FROM emp_history; www.TelechargerCours.com
  8. 8. 6-8 Copyright © Oracle Corporation, 1998. Tous droits réservés. UNION ALL AA BB www.TelechargerCours.com
  9. 9. 6-9 Copyright © Oracle Corporation, 1998. Tous droits réservés. Utilisation de l'Opérateur UNION ALL Affichez le nom, le numéro et le poste de tous les employés.Affichez le nom, le numéro et le poste de tous les employés. SQL> SELECT ename, empno, job 2 FROM emp 3 UNION ALL 4 SELECT name, empid, title 5 FROM emp_history; ENAME EMPNO JOB ---------- --------- --------- KING 7839 PRESIDENT BLAKE 7698 MANAGER CLARK 7782 MANAGER CLARK 7782 MANAGER MARTIN 7654 SALESMAN ... 23 rows selected. www.TelechargerCours.com
  10. 10. 6-10 Copyright © Oracle Corporation, 1998. Tous droits réservés. INTERSECT AA BB www.TelechargerCours.com
  11. 11. 6-11 Copyright © Oracle Corporation, 1998. Tous droits réservés. Utilisation de l'Opérateur INTERSECT Affichez les différents noms, numéros et postesAffichez les différents noms, numéros et postes des employés présents dans les tables EMP etdes employés présents dans les tables EMP et EMP_HISTORY.EMP_HISTORY. ENAME EMPNO JOB ---------- --------- --------- ALLEN 7499 SALESMAN CLARK 7782 MANAGER SCOTT 7788 ANALYST ENAME EMPNO JOB ---------- --------- --------- ALLEN 7499 SALESMAN CLARK 7782 MANAGER SCOTT 7788 ANALYST SQL> SELECT ename, empno, job 2 FROM emp 3 INTERSECT 4 SELECT name, empid, title 5 FROM emp_history; www.TelechargerCours.com
  12. 12. 6-12 Copyright © Oracle Corporation, 1998. Tous droits réservés. MINUS AA BB www.TelechargerCours.com
  13. 13. 6-13 Copyright © Oracle Corporation, 1998. Tous droits réservés. MINUS Affichez le nom,le numéro et le poste deAffichez le nom,le numéro et le poste de tous les employés ayant quitté la société.tous les employés ayant quitté la société. NAME EMPID TITLE ---------- --------- --------- BALFORD 6235 CLERK BRIGGS 7225 PAY CLERK JEWELL 7001 ANALYST SPENCER 6087 OPERATOR ... 6 rows selected. NAME EMPID TITLE ---------- --------- --------- BALFORD 6235 CLERK BRIGGS 7225 PAY CLERK JEWELL 7001 ANALYST SPENCER 6087 OPERATOR ... 6 rows selected. SQL> SELECT name, empid, title 2 FROM emp_history 3 MINUS 4 SELECT ename, empno, job 5 FROM emp; www.TelechargerCours.com
  14. 14. 6-14 Copyright © Oracle Corporation, 1998. Tous droits réservés. Règles des Opérateurs Ensemblistes • Les expressions citées dans la clause SELECT doivent être égales en nombre et avoir des données du même type. • Les doublons sont automatiquement éliminés, sauf avec l'opérateur UNION ALL. • Les noms de colonnes apparaissant dans le résultat sont ceux de la première requête. • Par défaut, le résultat est trié par ordre croissant, sauf avec l’opérateur UNION ALL. • Utilisez des parenthèses pour modifier la séquence d'exécution.
  15. 15. 6-15 Copyright © Oracle Corporation, 1998. Tous droits réservés. Correspondance des clauses SELECT SQL> SELECT deptno, TO_CHAR(NULL) location, hiredate 2 FROM emp 3 UNION 4 SELECT deptno, loc, TO_DATE(NULL) 5 FROM dept; SQL> SELECT deptno, TO_CHAR(NULL) location, hiredate 2 FROM emp 3 UNION 4 SELECT deptno, loc, TO_DATE(NULL) 5 FROM dept; Affichez le numéro du département, le lieuAffichez le numéro du département, le lieu et la date d'embauche de tous leset la date d'embauche de tous les employés.employés. DEPTNO LOCATION HIREDATE --------- ------------- --------- 10 NEW YORK 10 09-JUN-81 10 17-NOV-81 10 23-JAN-82 10 20 DALLAS 20 17-DEC-80 ... 19 rows selected. DEPTNO LOCATION HIREDATE --------- ------------- --------- 10 NEW YORK 10 09-JUN-81 10 17-NOV-81 10 23-JAN-82 10 20 DALLAS 20 17-DEC-80 ... 19 rows selected.
  16. 16. 6-16 Copyright © Oracle Corporation, 1998. Tous droits réservés. Contrôler l'Ordre des Lignes Créez une phrase anglaise à l'aide deCréez une phrase anglaise à l'aide de deux opérateurs UNION.deux opérateurs UNION. My dream ------------------------- I'd like to teach the world to sing My dream ------------------------- I'd like to teach the world to sing SQL> COLUMN a_dummy NOPRINT SQL> SELECT 'to sing' "My dream", 3 a_dummy 2 FROM dual 3 UNION 4 SELECT 'I''d like to teach', 1 5 FROM dual 6 UNION 7 SELECT 'the world', 2 8 FROM dual 9 ORDER BY 2; SQL> COLUMN a_dummy NOPRINT SQL> SELECT 'to sing' "My dream", 3 a_dummy 2 FROM dual 3 UNION 4 SELECT 'I''d like to teach', 1 5 FROM dual 6 UNION 7 SELECT 'the world', 2 8 FROM dual 9 ORDER BY 2; www.TelechargerCours.com
  17. 17. 6-17 Copyright © Oracle Corporation, 1998. Tous droits réservés. Résumé • L'opérateur UNION ramène toutes les lignes distinctes. • L'opérateur UNION ALL ramène toutes les lignes, y compris les doublons. • L'opérateur INTERSECT ramène toutes les lignes partagées par deux requêtes. • L'opérateur MINUS ramène toutes les lignes distinctes sélectionnées par la première requête, et non par la seconde. • La clause ORDER BY doit être placée à la fin de l'ordre. www.TelechargerCours.com

×