Introduction to Oracle9i: SQL1 Basic SQL SELECT Statements.

Slides:



Advertisements
Similar presentations
Sometimes you need to use data from more than one table. In example1, the report displays data from two separate tables. Employee IDs exist in the EMPLOYEES.
Advertisements

Chapter 4 Joining Multiple Tables
A Guide to SQL, Seventh Edition. Objectives Use joins to retrieve data from more than one table Use the IN and EXISTS operators to query multiple tables.
Virtual training week 4 structured query language (SQL)
Database Systems: Design, Implementation, and Management Tenth Edition
1Eyad Alshareef Enhanced Guide to Oracle 10g Chapter 3: Using SQL Queries to Insert, Update, Delete, and View Data.
Writing Basic SQL SELECT Statements. Capabilities of SQL SELECT Statements A SELECT statement retrieves information from the database. Using a SELECT.
Introduction to Structured Query Language (SQL)
Introduction to Structured Query Language (SQL)
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 8 Advanced SQL.
2 Copyright © 2004, Oracle. All rights reserved. Restricting and Sorting Data.
Writing Basic SQL statement 2 July July July Create By Pantharee Sawasdimongkol.
Introduction to Structured Query Language (SQL)
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 7 Introduction to Structured Query Language (SQL)
Microsoft Access 2010 Chapter 7 Using SQL.
WRITING BASIC SQL SELECT STATEMENTS Lecture 7 1. Outlines  SQL SELECT statement  Capabilities of SELECT statements  Basic SELECT statement  Selecting.
Ceng 356-Lab1. Objectives After completing this lesson, you should be able to do the following: Get Familiar with the development environment List the.
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
Concepts of Database Management, Fifth Edition
Chapter 2 Basic SQL SELECT Statements
ASP.NET Programming with C# and SQL Server First Edition
Chapter 2 Basic SQL SELECT Statements Oracle 10g: SQL.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
Chapter 9 Joining Data from Multiple Tables
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
2 Writing Basic SELECT Statements. 1-2 Copyright  Oracle Corporation, All rights reserved. Capabilities of SQL SELECT Statements Selection Projection.
Copyright  Oracle Corporation, All rights reserved. Writing Basic SQL Statements.
RELATSIOONILISED ANDMEBAASID(alg) SQLi VÕIMALUSED.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Oracle 11g DATABASE DEVELOPMENT LAB1. Introduction  Oracle 11g Database:-  Oracle 11g database is designed for some features, which helps to the organizations.
Chapter 4Introduction to Oracle9i: SQL1 Chapter 4 Joining Multiple Tables.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Introduction to SQL PART Ⅰ 第一讲 Writing Basic SQL SELECT Statements.
Chapter 4 Constraints Oracle 10g: SQL. Oracle 10g: SQL 2 Objectives Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
1 Writing Basic SQL Statements. 1-2 Objectives At the end of this lesson, you should be able to: List the capabilities of SQL SELECT statements Execute.
Copyright © 2004, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement Satrio Agung Wicaksono, S.Kom., M.Kom.
Copyright © 2004, Oracle. All rights reserved. Lecture 4: 1-Retrieving Data Using the SQL SELECT Statement 2-Restricting and Sorting Data Lecture 4: 1-Retrieving.
2 Copyright © 2004, Oracle. All rights reserved. Restricting and Sorting Data.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
2 Copyright © 2009, Oracle. All rights reserved. Restricting and Sorting Data.
1 Chapter 2 Basic SQL SELECT Statements. 2 Chapter Objectives Distinguish between an RDBMS and an ORDBMS Identify keywords, mandatory clauses, and optional.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Writing Basic SQL Statements. Objectives After completing this lesson, you should be able to do the following: –List the capabilities of SQL SELECT statements.
Writing Basic SQL SELECT Statements Lecture
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
 CONACT UC:  Magnific training   
1 Copyright © 2007, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
Oracle 10g Retrieving Data Using the SQL SELECT Statement.
1 Copyright © 2009, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
Copyright س Oracle Corporation, All rights reserved. 1 Writing Basic SQL Statements.
1 Copyright © 2004, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
Retrieving Data Using the SQL SELECT Statement
Writing Basic SQL SELECT Statements
Writing Basic SQL SELECT Statements
Chapter 1 Overview of Database Concepts
Basic select statement
Writing Basic SQL SELECT Statements
Retrieving Data Using the SQL SELECT Statement
Chapter # 7 Introduction to Structured Query Language (SQL) Part II.
Chapter 7 Introduction to Structured Query Language (SQL)
Writing Basic SQL SELECT Statements
Writing Basic SQL SELECT Statements
Contents Preface I Introduction Lesson Objectives I-2
Writing Basic SQL Statements
Retrieving Data Using the SQL SELECT Statement
Presentation transcript:

Introduction to Oracle9i: SQL1 Basic SQL SELECT Statements

Introduction to Oracle9i: SQL2 Chapter Objectives Distinguish between an RDBMS and an ORDBMS Identify keywords, mandatory clauses, and optional clauses in a SELECT statement Select and view all columns of a table Select and view one column of a table

Introduction to Oracle9i: SQL3 Chapter Objectives Display multiple columns of a table Use a column alias to clarify the contents of a particular column Perform basic arithmetic operations in the SELECT clause

Introduction to Oracle9i: SQL4 Chapter Objectives Remove duplicate lists, using either the DISTINCT or UNIQUE keyword Combine fields, literals, and other data Format output

Introduction to Oracle9i: SQL5 Relational Database Management System (RDBMS) An RDBMS is the software program used to create the database and it allows you to enter, manipulate, and retrieve data

Introduction to Oracle9i: SQL6 Object Relational Database Management System (ORDBMS) Same as an RDBMS except it can be used to reference objects such as maps and object fields

Introduction to Oracle9i: SQL7 SELECT Statement Syntax SELECT statements are used to retrieve data from the database Syntax gives the basic structure, or rules, for a command

Introduction to Oracle9i: SQL8 SELECT Statement Syntax Optional clauses and keywords are shown in brackets

Introduction to Oracle9i: SQL9 SELECT Statement Syntax SELECT and FROM clauses are required SELECT clause identifies column(s) FROM clause identifies table(s) Each clause begins with a keyword

Introduction to Oracle9i: SQL10 Selecting All Data in a Table Substitute an asterisk for the column names in a SELECT clause

Introduction to Oracle9i: SQL11 Selecting One Column from a Table Enter column name in SELECT clause

Introduction to Oracle9i: SQL12 Selecting Multiple Columns from a Table Separate column names with a comma

Introduction to Oracle9i: SQL13 Operations Within the SELECT Statement Column alias can be used for column headings Perform arithmetic operations Suppress duplicates Concatenate data

Introduction to Oracle9i: SQL14 Column Alias List after column heading AS keyword is optional Enclose in double quotation marks: –If it contains blank space(s) –If it contains special symbol(s) –To retain case

Introduction to Oracle9i: SQL15 Column Alias Example

Introduction to Oracle9i: SQL16 Arithmetic Operations Executed left to right Multiplication and division are solved first Addition and subtraction are solved last Override order with parentheses

Introduction to Oracle9i: SQL17 Example Arithmetic Operation with Column Alias

Introduction to Oracle9i: SQL18 Suppressing Duplicates Enter DISTINCT or UNIQUE after SELECT keyword

Introduction to Oracle9i: SQL19 Concatenation Can combine data with string literal Use concatenation operator, || Allows use of column alias

Introduction to Oracle9i: SQL20 Concatenation Example

Introduction to Oracle9i: SQL21 Purpose of Joins Joins are used to link tables and reconstruct data in a relational database Joins can be created through: –Conditions in a WHERE clause –Use of JOIN keywords in FROM clause

Introduction to Oracle9i: SQL22 Cartesian Join Created by omitting joining condition in the WHERE clause or through CROSS JOIN keywords in the FROM clause Results in every possible row combination (m * n)

Introduction to Oracle9i: SQL23 Cartesian Join Example: Omitted Condition

Introduction to Oracle9i: SQL24 Cartesian Join Example: CROSS JOIN Keywords

Introduction to Oracle9i: SQL25 Equality Join Links rows through equivalent data that exists in both tables Created by: –Creating equivalency condition in the WHERE clause –Using NATURAL JOIN, JOIN…USING, or JOIN…ON keywords in the FROM clause

Introduction to Oracle9i: SQL26 Equality Join: WHERE Clause Example

Introduction to Oracle9i: SQL27 Equality Join: NATURAL JOIN Syntax: tablename NATURAL JOIN tablename

Introduction to Oracle9i: SQL28 Equality Join: JOIN…USING Syntax: tablename JOIN tablename USING (columnname)

Introduction to Oracle9i: SQL29 Equality Join: JOIN…ON Syntax: tablename JOIN tablename ON condition

Introduction to Oracle9i: SQL30 JOIN Keyword Overview Use NATURAL JOIN when tables have one column in common Use JOIN…USING when tables have more than one column in common Use JOIN…ON when a condition is needed to specify a relationship other than equivalency Using JOIN keyword frees the WHERE clause for exclusive use in restricting rows

Introduction to Oracle9i: SQL31 Non-Equality Joins In WHERE clause, use any comparison operator other than equal sign In FROM clause, use JOIN…ON keywords with non-equivalent condition

Introduction to Oracle9i: SQL32 Non-Equality Join: WHERE Clause Example

Introduction to Oracle9i: SQL33 Non-Equality Join: JOIN…ON Example

Introduction to Oracle9i: SQL34 Self-Joins Used to link a table to itself Requires use of column qualifier

Introduction to Oracle9i: SQL35 Self-Join: WHERE Clause Example

Introduction to Oracle9i: SQL36 Self-Join: JOIN…ON Example

Introduction to Oracle9i: SQL37 Outer Joins // Use to include rows that do not have a match in the other table In WHERE clause, include outer join operator (+) next to table with missing rows to add NULL rows In FROM clause, use FULL, LEFT, or RIGHT with OUTER JOIN keywords

Introduction to Oracle9i: SQL38 Outer Join: WHERE Clause Example

Introduction to Oracle9i: SQL39 Outer Join: OUTER JOIN Keyword Example

Introduction to Oracle9i: SQL40 Set Operators XX Used to combine the results of two or more SELECT statements

Introduction to Oracle9i: SQL41 Set Operator Example

Introduction to Oracle9i: SQL42 Joining Three or More Tables Same procedure as joining two tables Will always results in one less join than the number of tables being joined

Introduction to Oracle9i: SQL43 Joining Three or More Tables: Example