Page 1
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 1/123
Introduction to Oracle9i : SQL Ravi Tejaswi Dhulipalla
Page 2
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 2/123
Agenda of the Today¶s session
SQL Intro
SQL Select
SQL Where
SQL Insert
SQL Update
SQL Delete SQL Order By
SQL AND & OR
SQL IN
SQL Between
SQL Alias
SQL Join
Page 3
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 3/123
SQL Introduction
Page 4
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 4/123
Objectives
SDLC
Page 5
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 5/123
Page 6
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 6/123
Strategy and Analysis
Study and analyze the business requirements. Interview users and managers toidentify the information requirements. Incorporate the enterprise and application
mission statements as well as any future system specifications. Build models of the system. Transfer the business narrative into a graphical
representation of business information needs and rules. Confirm and refine themodel with the analysts and experts.
Design
Design the database based on the model developed in the strategy and analysis phase.
Build and Document
Build the prototype system. Write and execute the commands to create the tables andsupporting objects for the database.
Develop user documentation, Help text, and operations manuals to support the use
and operation of the system.
Page 7
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 7/123
Transition
Refine the prototype. Move an application into production with user acceptance testing, conversion of existing data, and parallel operations. Make anymodifications required.
Production
Roll out the system to the users. Operate the production system. Monitor its performance, and enhance and refine the system.
Page 8
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 8/123
Page 9
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 9/123
Data: Pieces of information are called data .
Data Base : A database is an organized collection of information.
DBMS: To manage databases, you need database management systems
(DBMS). A DBMS is a program that stores, retrieves, and modifies data in
the database on request.
Page 10
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 10/123
Page 11
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 11/123
Page 12
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 12/123
Data Models:
Models are a cornerstone of design. Engineers build a model of a car to workout anydetails before putting it into production. In the same manner, system designersdevelop models to explore ideas and improve the understanding of the databasedesign.
Purpose of Models
Models help communicate the concepts in people¶s minds. They can be usedto do the following:
Communicate
Categorize
Describe
Specify
Investigate Evolve
Analyze
Imitate
The objective is to produce a model that fits a multitude of these uses, can beunderstood by an end user, and contains sufficient detail for a developer to build adatabase system.
Page 13
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 13/123
Entity: A thing of significance about which information needs to be known.
Examples are departments, employees, and orders.
Attribute: Something that describes or qualifies an entity. For example, for
the employee entity, the attributes would be the employee number, name,
job title, hire date, department number, and so on. Each of the attributes is
either required or optional. This state is called optionality.
Relationship: A named association between entities showing optionality and
degree. Examples
are employees and departments, and orders and items.
E
R Model :An Entity Relationship (ER) model is an illustration of variousentities in a business and the relationships between them. An ER model is
derived from business specifications or narratives and built during the
analysis phase of the system development life cycle
Page 14
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 14/123
Page 15
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 15/123
Benefits of ER Modeling:
Documents information for the organization in a clear, precise format
Provides a clear picture of the scope of the information requirement
Provides an easily understood pictorial map for the database design
Offers an effective framework for integrating multiple applications
Page 16
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 16/123
Page 17
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 17/123
Guidelines for Primary Keys and Foreign Keys
You cannot use duplicate values in a primary key.
Primary keys generally cannot be changed.
Foreign keys are based on data values and are purely logical, not physical,
pointers.
A foreign key value must match an existing primary key value or else be
null.
A foreign key must reference either a primary key column.
Page 18
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 18/123
Page 19
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 19/123
Page 20
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 20/123
Page 21
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 21/123
Page 22
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 22/123
Page 23
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 23/123
Objective
Select
Where
Insert Update
Delete
Page 24
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 24/123
Page 25
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 25/123
Page 26
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 26/123
Page 27
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 27/123
Page 28
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 28/123
Page 29
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 29/123
Page 30
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 30/123
Page 31
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 31/123
Page 32
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 32/123
Page 33
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 33/123
Page 34
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 34/123
Page 35
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 35/123
Page 36
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 36/123
Page 37
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 37/123
Page 38
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 38/123
Page 39
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 39/123
Page 40
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 40/123
Page 41
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 41/123
Page 42
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 42/123
Page 43
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 43/123
Page 44
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 44/123
Page 45
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 45/123
Describe Table Structure
Describe <table name>;
Page 46
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 46/123
Page 47
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 47/123
Manipulating Data
Page 48
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 48/123
Page 49
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 49/123
Page 50
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 50/123
Page 51
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 51/123
Page 52
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 52/123
Page 53
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 53/123
Page 54
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 54/123
Page 55
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 55/123
Page 56
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 56/123
Page 57
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 57/123
Page 58
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 58/123
Page 59
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 59/123
Page 60
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 60/123
Page 61
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 61/123
Page 62
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 62/123
Page 63
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 63/123
Page 64
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 64/123
Page 65
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 65/123
Page 66
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 66/123
Page 67
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 67/123
Page 68
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 68/123
Page 69
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 69/123
Page 70
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 70/123
Page 71
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 71/123
Page 72
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 72/123
Page 73
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 73/123
Page 74
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 74/123
Page 75
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 75/123
Page 76
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 76/123
Page 77
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 77/123
Page 78
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 78/123
Page 79
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 79/123
Page 80
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 80/123
Page 81
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 81/123
Page 82
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 82/123
Page 83
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 83/123
Page 84
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 84/123
Page 85
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 85/123
Page 86
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 86/123
Page 87
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 87/123
Page 88
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 88/123
Page 89
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 89/123
Page 90
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 90/123
Page 91
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 91/123
Page 92
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 92/123
Page 93
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 93/123
Page 94
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 94/123
Page 95
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 95/123
Page 96
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 96/123
Page 97
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 97/123
Page 98
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 98/123
Page 99
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 99/123
Page 100
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 100/123
Page 101
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 101/123
Page 102
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 102/123
Page 103
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 103/123
SQL JOINS
Page 104
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 104/123
Page 105
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 105/123
Page 106
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 106/123
Page 107
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 107/123
Page 108
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 108/123
Page 109
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 109/123
Page 110
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 110/123
Page 111
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 111/123
Page 112
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 112/123
Page 113
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 113/123
Page 114
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 114/123
Page 115
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 115/123
Page 116
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 116/123
Page 117
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 117/123
Page 118
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 118/123
Page 119
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 119/123
Page 120
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 120/123
Page 121
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 121/123
Page 122
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 122/123
Using the SQL: 1999 syntax, you can obtain the same results as were shown inthe prior pages.
In the syntax:
table1.column - Denotes the table and column from which data is retrieved
CROSS JOIN - Returns a Cartesian product from the two tables
NATU
RAL JOIN - Joins two tables based on the same column name JOIN table
USING column_name - Performs an equijoin based on the column name
JOIN table ON
table1.column_name -Performs an equijoin based on the condition in theON clause
= table2.column_name LEFT/RIGHT/FULL OUTER
Page 123
8/8/2019 Introduction to Oracle9i
http://slidepdf.com/reader/full/introduction-to-oracle9i 123/123
Thank you
Reach me at [email protected]