How to Get Data from Oracle to Postgresql and Vice Versa Who We Are

Total Page:16

File Type:pdf, Size:1020Kb

How to Get Data from Oracle to Postgresql and Vice Versa Who We Are How to get data from Oracle to PostgreSQL and vice versa Who we are The Company > Founded in 2010 > More than 70 specialists > Specialized in the Middleware Infrastructure > The invisible part of IT > Customers in Switzerland and all over Europe Our Offer > Consulting > Service Level Agreements (SLA) > Trainings > License Management How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 2 About me Daniel Westermann Principal Consultant Open Infrastructure Technology Leader +41 79 927 24 46 daniel.westermann[at]dbi-services.com @westermanndanie Daniel Westermann How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 3 How to get data from Oracle to PostgreSQL and vice versa Before we start We have a PostgreSQL user group in Switzerland! > https://www.swisspug.org Consider supporting us! How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 4 How to get data from Oracle to PostgreSQL and vice versa Before we start We have a PostgreSQL meetup group in Switzerland! > https://www.meetup.com/Switzerland-PostgreSQL-User-Group/ Consider joining us! How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 5 Agenda 1.Past, present and future 2.SQL/MED 3.Foreign data wrappers 4.Demo 5.Conclusion How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 6 Disclaimer This session is not about logical replication! If you are looking for this: > Data Replicator from DBPLUS > https://blog.dbi-services.com/real-time-replication-from-oracle-to-postgresql-using-data-replicator-from-dbplus/ > EDB xDB replication server > https://blog.dbi-services.com/replicating-from-oracle-to-postgresql-with-edb-replication-server-1-a-simple-replication- setup/ > Oracle GoldenGate > https://blog.dbi-services.com/?s=goldengate > SymmetricDS > https://www.symmetricds.org/ > (many more) How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 7 Past, present and future 1 2 3 4 5 How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 8 Past, present and future How did the database landscape look in the past? How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 9 Past, present and future How did the database landscape look in the past? In the past, the database landscape was quite simple > You either had this: How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 10 Past, present and future How did the database landscape look in the past? In the past, the database landscape was quite simple > Or this: How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 11 Past, present and future How did the database landscape look in the past? In the past, the database landscape was quite simple > Or even this: How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 12 Past, present and future How does it look today? How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 13 Past, present and future How does the database landscape look today? Today the situation is quite different How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 14 Past, present and future What will the future look like? How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 15 Past, present and future How does the database landscape look today? It will be even more challenging in the future How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 16 SQL/MED 1 2 3 4 5 How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 17 SQL/MED The SQL standard ISO/IEC 9075-9:2016 > Information technology - Database languages - SQL - Part 9: Management of External Data (SQL/MED) How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 18 SQL/MED The SQL standard SQL/MED provides extensions to SQL > Foreign data wrappers > Datalink types > a special SQL type intended to store URLs in database Provides the ability to deploy federated database systems > Using foreign data wrappers one system can manage data in many external systems How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 19 SQL/MED The SQL standard 1 SQL Server SQL/MED API Foreign data wrapper Implementation dependent API ... n Foreign data Foreign server (Foreign tables) How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 20 Foreign data wrappers 1 2 3 4 5 How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 21 Foreign data wrappers Why all this logos? There are foreign data wrappers for PostgreSQL for all those! How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 22 Foreign data wrappers Why all this logos? ... and actually there are much more > https://wiki.postgresql.org/wiki/Foreign_data_wrappers How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 23 Foreign data wrappers Accessing foreign data For accessing foreign data there needs to be a foreign data wrapper > A foreign data wrapper is a library that communicates with an external data source To access foreign data you need to create a foreign server > Defines how to connect to an external data source External data is available over foreign tables > Foreign tables are defined over foreign servers If the external data source requires authentication > A user mapping needs to be created How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 24 Foreign data wrappers Accessing foreign data You can, of course, also write your own foreign data wrapper > https://www.postgresql.org/docs/current/fdwhandler.html How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 25 Demo 1 2 3 4 5 How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 26 Demo The target setup oracle_fdw CentOS 8 stream Oracle Linux 7.7 PostgreSQL 12.1 Oracle EE 19.3 How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 27 Demo Before we start To give you an idea about foreign data wrappers > file_fdw is there by default > Can be used to access files with plain SQL > Similar to Oracle external tables postgres=# create extension file_fdw; CREATE EXTENSION postgres=# create table file ( dummy text ); CREATE TABLE postgres=# insert into file select i::text||','||i::text||','||i::text||','||i::text||','||i::text from generate_series(1,1000000) i; INSERT 0 1000000 postgres=# copy file to '/var/tmp/dummy.csv'; COPY 1000000 postgres=# \! head -5 /var/tmp/dummy.csv 1,1,1,1,1 … How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 28 Demo Before we start To give you an idea about foreign data wrappers postgres =# create server srv_file_fdw foreign data wrapper file_fdw; CREATE SERVER postgres=# create foreign table exttab ( a int, b int, c int, d int, e int) server srv_file_fdw options ( filename '/var/tmp/dummy.csv', format 'csv', header 'false' ); CREATE FOREIGN TABLE postgres=# select * from exttab limit 5; a | b | c | d | e ---+---+---+---+--- 1 | 1 | 1 | 1 | 1 2 | 2 | 2 | 2 | 2 3 | 3 | 3 | 3 | 3 4 | 4 | 4 | 4 | 4 5 | 5 | 5 | 5 | 5 (5 rows) How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 29 Demo Steps to do The procedure for getting the oracle_fdw up and runnig is > (PostgreSQL should already be up and running) > Download the Oracle instant client zip files > Configure and test Oracle instant client > Download oracle_fdw > Build oracle_fdw against the Oracle instant client libraries > Teach PostgreSQL where to find the Oracle libraries > Create a foreign server > Create a user mapping > Create a schema > Import the foreign schema > Have fun ... Don't worry, all the steps showed live, are in the slides as well! How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 30 Demo Oracle instant client The oracle_fdw will need the Oracle client libraries > Oracle instant client is perfect for that > https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html What you'll need to replay the demo is > Basic Package (ZIP) > SQL*Plus Package (ZIP), for testing the connection to Oracle > SDK Package (ZIP), the header files required for building oracle_fdw We will use the zip distribution so the same can be replayed on Debian based distributions > Works the same on Ubuntu, Debian, SUSE or any other Linux distribution How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 31 Demo Oracle instant client The Oracle instant client zip files postgres@pg-fdw-oracle:/home/postgres/ [PG1] pwd /home/postgres postgres@pg-fdw-oracle:/home/postgres/ [PG1] ls -l total 75220 -rw-rw-r--. 1 postgres postgres 14:44 instantclient-basic-linux.x64-19.5.0.0.0dbru.zip -rw-rw-r--. 1 postgres postgres 14:44 instantclient-sdk-linux.x64-19.5.0.0.0dbru.zip -rw-rw-r--. 1 postgres postgres 14:44 instantclient-sqlplus-linux.x64-19.5.0.0.0dbru.zip postgres@pg-fdw-oracle:/home/postgres/ [PG1] How to get data from Oracle to PostgreSQL and vice versa 19.06.2020 Page 32 Demo Oracle instant client Preparing Oracle instant client postgres@pg-fdw-oracle: [PG1] unzip instantclient-basic-linux.x64-19.5.0.0.0dbru.zip postgres@pg-fdw-oracle: [PG1] unzip instantclient-sdk-linux.x64-19.5.0.0.0dbru.zip postgres@pg-fdw-oracle: [PG1] unzip instantclient-sqlplus-linux.x64-19.5.0.0.0dbru.zip postgres@pg-fdw-oracle: [PG1] ls instantclient_19_5/ adrci libclntsh.so libipc1.so libocci.so.12.1 libsqlplusic.so SDK_README xstreams.jar BASIC_LICENSE libclntsh.so.10.1 libmql1.so libocci.so.18.1 libsqlplus.so Sqlplus BASIC_README libclntsh.so.11.1
Recommended publications
  • Database Concepts 7Th Edition
    Database Concepts 7th Edition David M. Kroenke • David J. Auer Online Appendix E SQL Views, SQL/PSM and Importing Data Database Concepts SQL Views, SQL/PSM and Importing Data Appendix E All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. Printed in the United States of America. Appendix E — 10 9 8 7 6 5 4 3 2 1 E-2 Database Concepts SQL Views, SQL/PSM and Importing Data Appendix E Appendix Objectives • To understand the reasons for using SQL views • To use SQL statements to create and query SQL views • To understand SQL/Persistent Stored Modules (SQL/PSM) • To create and use SQL user-defined functions • To import Microsoft Excel worksheet data into a database What is the Purpose of this Appendix? In Chapter 3, we discussed SQL in depth. We discussed two basic categories of SQL statements: data definition language (DDL) statements, which are used for creating tables, relationships, and other structures, and data manipulation language (DML) statements, which are used for querying and modifying data. In this appendix, which should be studied immediately after Chapter 3, we: • Describe and illustrate SQL views, which extend the DML capabilities of SQL. • Describe and illustrate SQL Persistent Stored Modules (SQL/PSM), and create user-defined functions. • Describe and use DBMS data import techniques to import Microsoft Excel worksheet data into a database. E-3 Database Concepts SQL Views, SQL/PSM and Importing Data Appendix E Creating SQL Views An SQL view is a virtual table that is constructed from other tables or views.
    [Show full text]
  • Sql Create Table Variable from Select
    Sql Create Table Variable From Select Do-nothing Dory resurrect, his incurvature distasting crows satanically. Sacrilegious and bushwhacking Jamey homologising, but Harcourt first-hand coiffures her muntjac. Intertarsal and crawlier Towney fanes tenfold and euhemerizing his assistance briskly and terrifyingly. How to clean starting value inside of data from select statements and where to use matlab compiler to store sql, and then a regular join You may not supported for that you are either hive temporary variable table. Before we examine the specific methods let's create an obscure procedure. INSERT INTO EXEC sql server exec into table. Now you can show insert update delete and invent all operations with building such as in pay following a write i like the Declare TempTable. When done use t or t or when to compact a table variable t. Procedure should create the temporary tables instead has regular tables. Lesson 4 Creating Tables SQLCourse. EXISTS tmp GO round TABLE tmp id int NULL SELECT empire FROM. SQL Server How small Create a Temp Table with Dynamic. When done look sir the Execution Plan save the SELECT Statement SQL Server is. Proc sql create whole health will select weight married from myliboutdata ORDER to weight ASC. How to add static value while INSERT INTO with cinnamon in a. Ssrs invalid object name temp table. Introduction to Table Variable Deferred Compilation SQL. How many pass the bash array in 'right IN' clause will select query. Creating a pope from public Query Vertica. Thus attitude is no performance cost for packaging a SELECT statement into an inline.
    [Show full text]
  • Look out the Window Functions and Free Your SQL
    Concepts Syntax Other Look Out The Window Functions and free your SQL Gianni Ciolli 2ndQuadrant Italia PostgreSQL Conference Europe 2011 October 18-21, Amsterdam Look Out The Window Functions Gianni Ciolli Concepts Syntax Other Outline 1 Concepts Aggregates Different aggregations Partitions Window frames 2 Syntax Frames from 9.0 Frames in 8.4 3 Other A larger example Question time Look Out The Window Functions Gianni Ciolli Concepts Syntax Other Aggregates Aggregates 1 Example of an aggregate Problem 1 How many rows there are in table a? Solution SELECT count(*) FROM a; • Here count is an aggregate function (SQL keyword AGGREGATE). Look Out The Window Functions Gianni Ciolli Concepts Syntax Other Aggregates Aggregates 2 Functions and Aggregates • FUNCTIONs: • input: one row • output: either one row or a set of rows: • AGGREGATEs: • input: a set of rows • output: one row Look Out The Window Functions Gianni Ciolli Concepts Syntax Other Different aggregations Different aggregations 1 Without window functions, and with them GROUP BY col1, . , coln window functions any supported only PostgreSQL PostgreSQL version version 8.4+ compute aggregates compute aggregates via by creating groups partitions and window frames output is one row output is one row for each group for each input row Look Out The Window Functions Gianni Ciolli Concepts Syntax Other Different aggregations Different aggregations 2 Without window functions, and with them GROUP BY col1, . , coln window functions only one way of aggregating different rows in the same for each group
    [Show full text]
  • SQL and Management of External Data
    SQL and Management of External Data Jan-Eike Michels Jim Melton Vanja Josifovski Oracle, Sandy, UT 84093 Krishna Kulkarni [email protected] Peter Schwarz Kathy Zeidenstein IBM, San Jose, CA {janeike, vanja, krishnak, krzeide}@us.ibm.com [email protected] SQL/MED addresses two aspects to the problem Guest Column Introduction of accessing external data. The first aspect provides the ability to use the SQL interface to access non- In late 2000, work was completed on yet another part SQL data (or even SQL data residing on a different of the SQL standard [1], to which we introduced our database management system) and, if desired, to join readers in an earlier edition of this column [2]. that data with local SQL data. The application sub- Although SQL database systems manage an mits a single SQL query that references data from enormous amount of data, it certainly has no monop- multiple sources to the SQL-server. That statement is oly on that task. Tremendous amounts of data remain then decomposed into fragments (or requests) that are in ordinary operating system files, in network and submitted to the individual sources. The standard hierarchical databases, and in other repositories. The does not dictate how the query is decomposed, speci- need to query and manipulate that data alongside fying only the interaction between the SQL-server SQL data continues to grow. Database system ven- and foreign-data wrapper that underlies the decompo- dors have developed many approaches to providing sition of the query and its subsequent execution. We such integrated access. will call this part of the standard the “wrapper inter- In this (partly guested) article, SQL’s new part, face”; it is described in the first half of this column.
    [Show full text]
  • Handling Missing Values in the SQL Procedure
    Handling Missing Values in the SQL Procedure Danbo Yi, Abt Associates Inc., Cambridge, MA Lei Zhang, Domain Solutions Corp., Cambridge, MA non-missing numeric values. A missing ABSTRACT character value is expressed and treated as a string of blanks. Missing character values PROC SQL as a powerful database are always same no matter whether it is management tool provides many features expressed as one blank, or more than one available in the DATA steps and the blanks. Obviously, missing character values MEANS, TRANSPOSE, PRINT and SORT are not the smallest strings. procedures. If properly used, PROC SQL often results in concise solutions to data In SAS system, the way missing Date and manipulations and queries. PROC SQL DateTime values are expressed and treated follows most of the guidelines set by the is similar to missing numeric values. American National Standards Institute (ANSI) in its implementation of SQL. This paper will cover following topics. However, it is not fully compliant with the 1. Missing Values and Expression current ANSI Standard for SQL, especially · Logic Expression for the missing values. PROC SQL uses · Arithmetic Expression SAS System convention to express and · String Expression handle the missing values, which is 2. Missing Values and Predicates significantly different from many ANSI- · IS NULL /IS MISSING compatible SQL databases such as Oracle, · [NOT] LIKE Sybase. In this paper, we summarize the · ALL, ANY, and SOME ways the PROC SQL handles the missing · [NOT] EXISTS values in a variety of situations. Topics 3. Missing Values and JOINs include missing values in the logic, · Inner Join arithmetic and string expression, missing · Left/Right Join values in the SQL predicates such as LIKE, · Full Join ANY, ALL, JOINs, missing values in the 4.
    [Show full text]
  • Symmetricds User Guide
    SymmetricDS User Guide v3.4 Copyright © 2007 - 2013 Eric Long, Chris Henson, Mark Hanes, Greg Wilmer Permission to use, copy, modify, and distribute the SymmetricDS User Guide Version 3.4 for any purpose and without fee is hereby granted in perpetuity, provided that the above copyright notice and this paragraph appear in all copies. SymmetricDS v3.4 Table of Contents Preface ................................................................................................................................................ ix 1. Introduction ..................................................................................................................................... 1 1.1. System Requirements ........................................................................................................... 1 1.2. Overview .............................................................................................................................. 1 1.2.1. A Node is Born ......................................................................................................... 3 1.2.2. Capturing Changes .................................................................................................... 4 1.2.3. Change Delivery ....................................................................................................... 4 1.2.4. Channeling Data ........................................................................................................ 5 1.3. Features ...............................................................................................................................
    [Show full text]
  • Firebird 3 Windowing Functions
    Firebird 3 Windowing Functions Firebird 3 Windowing Functions Author: Philippe Makowski IBPhoenix Email: pmakowski@ibphoenix Licence: Public Documentation License Date: 2011-11-22 Philippe Makowski - IBPhoenix - 2011-11-22 Firebird 3 Windowing Functions What are Windowing Functions? • Similar to classical aggregates but does more! • Provides access to set of rows from the current row • Introduced SQL:2003 and more detail in SQL:2008 • Supported by PostgreSQL, Oracle, SQL Server, Sybase and DB2 • Used in OLAP mainly but also useful in OLTP • Analysis and reporting by rankings, cumulative aggregates Philippe Makowski - IBPhoenix - 2011-11-22 Firebird 3 Windowing Functions Windowed Table Functions • Windowed table function • operates on a window of a table • returns a value for every row in that window • the value is calculated by taking into consideration values from the set of rows in that window • 8 new windowed table functions • In addition, old aggregate functions can also be used as windowed table functions • Allows calculation of moving and cumulative aggregate values. Philippe Makowski - IBPhoenix - 2011-11-22 Firebird 3 Windowing Functions A Window • Represents set of rows that is used to compute additionnal attributes • Based on three main concepts • partition • specified by PARTITION BY clause in OVER() • Allows to subdivide the table, much like GROUP BY clause • Without a PARTITION BY clause, the whole table is in a single partition • order • defines an order with a partition • may contain multiple order items • Each item includes
    [Show full text]
  • Using the Set Operators Questions
    UUSSIINNGG TTHHEE SSEETT OOPPEERRAATTOORRSS QQUUEESSTTIIOONNSS http://www.tutorialspoint.com/sql_certificate/using_the_set_operators_questions.htm Copyright © tutorialspoint.com 1.Which SET operator does the following figure indicate? A. UNION B. UNION ALL C. INTERSECT D. MINUS Answer: A. Set operators are used to combine the results of two ormore SELECT statements.Valid set operators in Oracle 11g are UNION, UNION ALL, INTERSECT, and MINUS. When used with two SELECT statements, the UNION set operator returns the results of both queries.However,if there are any duplicates, they are removed, and the duplicated record is listed only once.To include duplicates in the results,use the UNION ALL set operator.INTERSECT lists only records that are returned by both queries; the MINUS set operator removes the second query's results from the output if they are also found in the first query's results. INTERSECT and MINUS set operations produce unduplicated results. 2.Which SET operator does the following figure indicate? A. UNION B. UNION ALL C. INTERSECT D. MINUS Answer: B. UNION ALL Returns the combined rows from two queries without sorting or removing duplicates. sql_certificate 3.Which SET operator does the following figure indicate? A. UNION B. UNION ALL C. INTERSECT D. MINUS Answer: C. INTERSECT Returns only the rows that occur in both queries' result sets, sorting them and removing duplicates. 4.Which SET operator does the following figure indicate? A. UNION B. UNION ALL C. INTERSECT D. MINUS Answer: D. MINUS Returns only the rows in the first result set that do not appear in the second result set, sorting them and removing duplicates.
    [Show full text]
  • Relational Algebra and SQL Relational Query Languages
    Relational Algebra and SQL Chapter 5 1 Relational Query Languages • Languages for describing queries on a relational database • Structured Query Language (SQL) – Predominant application-level query language – Declarative • Relational Algebra – Intermediate language used within DBMS – Procedural 2 1 What is an Algebra? · A language based on operators and a domain of values · Operators map values taken from the domain into other domain values · Hence, an expression involving operators and arguments produces a value in the domain · When the domain is a set of all relations (and the operators are as described later), we get the relational algebra · We refer to the expression as a query and the value produced as the query result 3 Relational Algebra · Domain: set of relations · Basic operators: select, project, union, set difference, Cartesian product · Derived operators: set intersection, division, join · Procedural: Relational expression specifies query by describing an algorithm (the sequence in which operators are applied) for determining the result of an expression 4 2 The Role of Relational Algebra in a DBMS 5 Select Operator • Produce table containing subset of rows of argument table satisfying condition σ condition (relation) • Example: σ Person Hobby=‘stamps’(Person) Id Name Address Hobby Id Name Address Hobby 1123 John 123 Main stamps 1123 John 123 Main stamps 1123 John 123 Main coins 9876 Bart 5 Pine St stamps 5556 Mary 7 Lake Dr hiking 9876 Bart 5 Pine St stamps 6 3 Selection Condition • Operators: <, ≤, ≥, >, =, ≠ • Simple selection
    [Show full text]
  • SQL/PSM Stored Procedures Basic PSM Form Parameters In
    Stored Procedures PSM, or “persistent, stored modules,” SQL/PSM allows us to store procedures as database schema elements. PSM = a mixture of conventional Procedures Stored in the Database statements (if, while, etc.) and SQL. General-Purpose Programming Lets us do things we cannot do in SQL alone. 1 2 Basic PSM Form Parameters in PSM CREATE PROCEDURE <name> ( Unlike the usual name-type pairs in <parameter list> ) languages like C, PSM uses mode- <optional local declarations> name-type triples, where the mode can be: <body>; IN = procedure uses value, does not Function alternative: change value. CREATE FUNCTION <name> ( OUT = procedure changes, does not use. <parameter list> ) RETURNS <type> INOUT = both. 3 4 1 Example: Stored Procedure The Procedure Let’s write a procedure that takes two CREATE PROCEDURE JoeMenu ( arguments b and p, and adds a tuple IN b CHAR(20), Parameters are both to Sells(bar, beer, price) that has bar = IN p REAL read-only, not changed ’Joe’’s Bar’, beer = b, and price = p. ) Used by Joe to add to his menu more easily. INSERT INTO Sells The body --- VALUES(’Joe’’s Bar’, b, p); a single insertion 5 6 Invoking Procedures Types of PSM statements --- (1) Use SQL/PSM statement CALL, with the RETURN <expression> sets the return name of the desired procedure and value of a function. arguments. Unlike C, etc., RETURN does not terminate Example: function execution. CALL JoeMenu(’Moosedrool’, 5.00); DECLARE <name> <type> used to declare local variables. Functions used in SQL expressions wherever a value of their return type is appropriate.
    [Show full text]
  • SQL Subqueries and Set Operations
    The Islamic University of Gaza Faculty of Engineering Dept. of Computer Engineering Database Lab (ECOM 4113) Lab 3 SQL Subqueries and Set Operations Eng. Ibraheem Lubbad Nested Queries (subqueries): A subquery is a SELECT statement that is embedded in the clause of another SELECT statement. You can build a powerful statements out of simple ones by using subqueries. You can write subqueries in the WHERE clause of another SQL statement to obtain values based on an unknown conditional value Subquery Syntax: SELECT SELECT_LIST FROM TABLE WHERE EXPR OPERATOR (SELECT SELECT_LIST FROM TABLE ); The subquery (inner query) executes before the main query (outer query). The result of the subquery is used by main query Example: Find all students who are study in departments Computer Science AND their total credit is greater than ALL students in Elec. Eng. First solution: retrieve targeted students with two steps; firstly, retrieve total credit of all students in Elec. Eng. (without duplication), then, use the retrieve values in another query. The first query First Query SELECT TOT_CRED FROM STUDENT WHERE DEPT_NAME='Elec. Eng.’; Second Query SELECT * FROM STUDENT WHERE DEPT_NAME='Comp. Sci.' AND TOT_CRED > ALL(60,80) The previous solution is not wrong. However, it is not a practical solution since you apply it with many steps and each step needs a human to do them (cannot applied by machine since the retrieve values are dynamic and can be changed in any time. A better solution is to embedded the first query in the second query in “All’s condition parentheses”, which is called: sub query Another Way Query SELECT * FROM STUDENT OUTER QUERY WHERE DEPT_NAME='Comp.
    [Show full text]
  • Main Page 1 Main Page
    Main Page 1 Main Page FLOSSMETRICS/ OpenTTT guides FLOSS (Free/Libre open source software) is one of the most important trends in IT since the advent of the PC and commodity software, but despite the potential impact on European firms, its adoption is still hampered by limited knowledge, especially among SMEs that could potentially benefit the most from it. This guide (developed in the context of the FLOSSMETRICS and OpenTTT projects) present a set of guidelines and suggestions for the adoption of open source software within SMEs, using a ladder model that will guide companies from the initial selection and adoption of FLOSS within the IT infrastructure up to the creation of suitable business models based on open source software. The guide is split into an introduction to FLOSS and a catalog of open source applications, selected to fulfill the requests that were gathered in the interviews and audit in the OpenTTT project. The application areas are infrastructural software (ranging from network and system management to security), ERP and CRM applications, groupware, document management, content management systems (CMS), VoIP, graphics/CAD/GIS systems, desktop applications, engineering and manufacturing, vertical business applications and eLearning. This is the third edition of the guide; the guide is distributed under a CC-attribution-sharealike 3.0 license. The author is Carlo Daffara ([email protected]). The complete guide in PDF format is avalaible here [1] Free/ Libre Open Source Software catalog Software: a guide for SMEs • Software Catalog Introduction • SME Guide Introduction • 1. What's Free/Libre/Open Source Software? • Security • 2. Ten myths about free/libre open source software • Data protection and recovery • 3.
    [Show full text]