Chapter Five Data Manipulation Language (DML) Objectives Oracle DBMS Understanding the DML General format of SQL Capability of SELECT statement Use of.

Slides:



Advertisements
Similar presentations
Copyright  Oracle Corporation, All rights reserved. 1 Writing Basic SQL Statements.
Advertisements

1Eyad Alshareef Enhanced Guide to Oracle 10g Chapter 3: Using SQL Queries to Insert, Update, Delete, and View Data.
SQL Review Sections 1 - SQL and other basic statements.
1 Chapter Seven (part 2) Multiple Row Functions: Objectives: -Multiple row functions -Ordering -Grouping -Concept of JOIN.
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. Capabilities of SQL SELECT Statements A SELECT statement retrieves information from the database. Using a SELECT.
Restricting and Sorting Data. Consider the table employee(employee_id,last_name,job_id, department_id ) assume that you want to display all the employees.
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
Writing Basic SQL statement 2 July July July Create By Pantharee Sawasdimongkol.
WRITING BASIC SQL SELECT STATEMENTS Lecture 7 1. Outlines  SQL SELECT statement  Capabilities of SELECT statements  Basic SELECT statement  Selecting.
Chapter 1 Writing Basic SQL Statements Important Legal Notice:  Materials on this lecture are from a book titled “Oracle Education” by Kochhar, Gravina,
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.
Chapter 2 Basic SQL SELECT Statements
Chapter 2 Basic SQL SELECT Statements Oracle 10g: SQL.
Working with Tables: Data Management and Retrieval Dr. Bernard Chen Ph.D. University of Central Arkansas.
1 Copyright © 2006, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
Chapter Four Objectives Introduction to SQL Types of SQL statements Concepts of DDL & DML Creating Tables Restrictions on Tables Data Definition Language(DDL)
Copyright  Oracle Corporation, All rights reserved. 1 Writing Basic SQL Statements.
Much from Introduction to Oracle:SQL and PL/SQL, Oracle University 1 Basic SQL Statements Oracle/SQL Plus Commands Kroenke, 11 th ed., Chapter Two.
1 Chapter Nine Data Manipulation Language (DML) Views Objectives Definition Creating views Retrieve data from a view Drop a view.
After completing this lesson, you should be able to do the following: List the capabilities of MySQL SELECT statements Execute a basic SELECT statement.
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.
Copyright س Oracle Corporation, All rights reserved. I Introduction.
RELATSIOONILISED ANDMEBAASID(alg) SQLi VÕIMALUSED.
Oracle 11g DATABASE DEVELOPMENT LAB1. Introduction  Oracle 11g Database:-  Oracle 11g database is designed for some features, which helps to the organizations.
Introduction to SQL PART Ⅰ 第一讲 Writing Basic SQL SELECT Statements.
5. Simple SQL using Oracle1 Simple SQL using Oracle 5. Working with Tables: Data management and Retrieval 6. Working with Tables: Functions and Grouping.
Database Management COP4540, SCS, FIU Structured Query Language (Chapter 8)
IFS Intro to Data Management Chapter 5 Getting More Than Simple Columns.
Chapter Eight Data Manipulation Language (DML) Objectives Oracle DBMS Understanding the DML General format of SQL Capability of SELECT statement Use of.
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.
5. Simple SQL using Oracle1 Simple SQL using Oracle 5. Working with Tables: Data management and Retrieval 6. Working with Tables: Functions and Grouping.
I-1 Copyright س Oracle Corporation, All rights reserved. Data Retrieval.
1 Chapter Ten Multiple Row Functions/Join: Objectives: -Multiple row functions -Ordering -Grouping -Concept of JOIN.
Chapter Eleven Data Manipulation Language (DML) Nested Queries Dr. Chitsaz Objectives Nested queries Application of nested queries Conditions on nested.
SqlExam1Review.ppt EXAM - 1. SQL stands for -- Structured Query Language Putting a manual database on a computer ensures? Data is more current Data is.
Working with Columns, Characters, and Rows. 2 home back first prev next last What Will I Learn? In this lesson, you will learn to: –Apply the concatenation.
Chapter Twelve Report Writing Objectives: -Writing reports -Page set up -Page layout.
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
Copyright س Oracle Corporation, All rights reserved. I Introduction.
1 Chapter 2 Basic SQL SELECT Statements. 2 Chapter Objectives Distinguish between an RDBMS and an ORDBMS Identify keywords, mandatory clauses, and optional.
Chapter Five Objectives Insert Data into tables Create Query files to insert data into tables Make changes to the data in the tables Extract data from.
1-1 Copyright  Oracle Corporation, All rights reserved. Logging In to SQL*Plus From Windows environment:From Windows environment: From command line:From.
9/29/2005From Introduction to Oracle:SQL and PL/SQL, Oracle 1 Restricting and Sorting Data Kroenke, Chapter Two.
Chapter 21: Report writing1 Chapter Twenty One Producing Readable Output Objectives: Writing reports Page set up Page layout Queries with input.
Writing Basic SQL Statements. Objectives After completing this lesson, you should be able to do the following: –List the capabilities of SQL SELECT statements.
1 Copyright © 2007, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
Chapter Four Objectives Introduction to SQL Introduction to iSQL*PLUS Types of SQL statements Concepts of DDL & DML Data Manipulation Language (DML)
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.
Restricting and Sorting Data
RELATSIOONILISED ANDMEBAASID (algus , ORACLE materjalid)
Retrieving Data Using the SQL SELECT Statement
Writing Basic SQL SELECT Statements
Writing Basic SQL SELECT Statements
Basic select statement
Writing Basic SQL SELECT Statements
Retrieving Data Using the SQL SELECT Statement
Writing Basic SQL SELECT Statements
Contents Preface I Introduction Lesson Objectives I-2
Writing Basic SQL Statements
Retrieving Data Using the SQL SELECT Statement
Restricting and Sorting Data
Presentation transcript:

Chapter Five Data Manipulation Language (DML) Objectives Oracle DBMS Understanding the DML General format of SQL Capability of SELECT statement Use of Operators String Processing Concept of NULL Conditional Statement

2 Example: Student(Name, ID, GPA, Major, B_Date) Course(C_Num, Dept, Title, Cr) Student_Course(ID, C_Num, Dept, Grade) Faculty(ID, Name, Dept, Salary, Area) Faculty_Course(ID, C_Num, Dept, Semester) Department(Name, Num_Faculty) Tables

3 General Format SELECT fieldnames FROM relation [ WHERE condition] [ GROUP BY group_field ] [ HAVING condition] [ ORDER BY fieldname] ;

4 Select Attributes: Example: Show the name and GPA of the students (ALL). SELECT name, GPA FROMstudent;

5 Select Attributes: Example: List all the columns in course SELECT* FROMcourse;

6 General Format Table display: Default justification: -Date and charactersLEFT -NumberRIGHT Default display: -Uppercase

7 General Format NAMEGPA MARY 3.1

8 Practice:  List all columns in customer table

9 Duplicated Rows Example: List of the course credits offered at FSU. SELECT Cr FROMCourse;

10 Use of Distinct: Example: Type of the course credits offered at FSU. SELECT DISTINCT Cr FROMCourse;

11 Practice:  List of cities in customer table. (Unique city name)

12 Use of Aliases: Example: List of the faculty’s name and their salary per month. SELECT name, salary / 12 FROM faculty;

13 Use of Aliases: Rename column heading Example: List of the faculty salary for next year with 5% increase. SELECT name, salary Pay, salary+salary*0.05 AS New_Salary FROM faculty;

14 Use of Aliases: NAMEPAY NEW_SALARY

15 Practice:  Produce the following list: Customer_City Customer_State Customer_Zip_Code

16 Use of Arithmetic Operations: () -, *, / +, - Operation of some priority is evaluated from left to right 5* (2+1)

17 Use of Arithmetic Operations: Example: List the course numbers and credits in a quarter system SELECTC_Num, Cr * 0.75 FROMCourse;

18 Use of Concatenation: Example: List of faculty and department as a unit SELECTname || dept “Name:” FROM faculty; Name: CHITSAZCOSC

19 Use of Literal: Example: List of faculty and department SELECTname || ‘ ‘ || ‘is in ’ || dept “Department Name:” FROM faculty; Department Name: CHITSAZ is in COSC

20 Condition statements: SELECTname, GPA FROMstudent WHEREGPA > 2;

21 Condition Operators: =, >, >=, != ^= IN BETWEEN..... AND..... LIKE IS NULL AND, OR, NOT

22 String & Date Comparison Example: List the students who born on March 2, 99 SELECTname FROMstudent WHEREB_Date =’02-MAR-99’ ; Date Format ‘DD-MON-YY’

23 Use of Boolean Operations: Example: List of Student names that have a GPA > 3 and majoring in COSC SELECTname FROMstudent WHEREGPA > 3 AND major = 'COSC'; Character string is case sensitive & should be in a single quotation mark

24 Question  What kind of information you get if you use this condition: SELECTname FROMstudent WHEREGPA > 3 OR major = 'COSC';

25 Question  What kind of information you get if you use this condition: SELECTname FROMstudent WHERE(GPA > 3 AND major = 'COSC') OR(GPA>2.5 AND major=‘ART ’);

26 Practice:  List of Last name, First name of customers with a balance > 2000 and their birth date is before March, 01, 1985.

27 Precedence Rule: >, >=, <>, <=, =, NOT AND OR

28 Practice:  List Last name of customer which have a balance >100 or credit limit <2000 and live in MD from the customer table.

29 Null vs. No Value Null value is: Unavailable Unassigned Unknown Inapplicable Examples: Null is not the same as zero or blank

30 Null vs. No Value SELECTname, Major FROMStudent; SELECTname, Num_Faculty FROMDepartment;

31 Null Values in Expressions Result of an arithmetic expression with a null value is null. SELECTname, GPA*0.75 FROMStudent;

32 Null vs. No Value List of students with no major SELECTname FROMStudent WHEREmajor IS NULL; SELECTname FROMStudent WHEREmajor IS NOT NULL;

33 Null vs. No Value NVL Null Value substitution: We can substitute a value for a NULL value record by using NVL. List of students and their major: SELECTname, NVL(major, ‘unknown’) FROMStudent; SELECT name, NVL(GPA, 0.0) FROM Student;

34 Practice:  List of customer first and last names which have not been assigned a sales rep. number.

35 Use of Between BETWEEN: Test against a list of values: (Check the data in a range) List description of courses with the course number between 200 AND 299 SELECTTitle FROMCourse WHEREC_Num BETWEEN 200 AND 299;

36 Use of Between SELECTTitle FROMCourse WHERE C_Num NOT BETWEEN 200 AND 299; SELECTTitle FROMCourse WHERE (C_Num >= 200) AND (C_Num <= 299);

37 Use of Between List of Faculty’s name from D to E SELECTname FROMfaculty WHERE name BETWEEN ‘D’ AND ‘E’;

38 Question  List of names starting with D only!

39 Practice:  List the order numbers of items with a order quoted price between $100 and $1000

40 Use of IN IN: Tests against a list of values: (Set of values used for comparison) List of students with ID = 1111, ID = 2111 or ID = 3111 SELECTname FROMStudent WHERE ID IN (1111, 2111, 3111);

41 Use of IN SELECTname FROMStudent WHERE major IN (‘COSC’, ‘MATH’); SELECT name FROM Student WHERE major NOT IN (‘COSC’, ‘MATH’);

42 Practice:  List customer number, first and last name of customers with Zip code of or or or 11001

43 Use of LIKE LIKE: Determines the presence of a sub string (_) a single unknown character (%) any number of unknown characters

44 Use of LIKE List all the student’s records so that the student’s name starts with a ‘K’ SELECT* FROMStudent WHERE name LIKE ‘K%’;

45 Use of LIKE List of students records with the second character to be ‘K’ SELECT* FROMStudent WHERE name LIKE ‘_K’;

46 Practice:  List of customers with the last name ending with “SON” like Jackson, Nelson, Larson.

47 Practice:  List of customer Last names who live in a street name which has a character string ‘upper’ like ‘South upper Potomac’, ‘upper Dakota’, ‘Magnolia upper’