Академический Документы
Профессиональный Документы
Культура Документы
Objectives
After completing this lesson, you should be able to do
the following:
List the capabilities of SQL SELECT statements
Execute a basic SELECT statement
Differentiate between SQL statements and
iSQL*Plus commands
1-2
Selection
Table 1
Table 1
Join
Table 1
1-3
Table 2
Copyright 2004, Oracle. All rights reserved.
1-4
SELECT *
FROM
departments;
1-5
1-6
1-7
iSQL*Plus:
Default heading alignment: Center
Default heading display: Uppercase
SQL*Plus:
Character and Date column headings are leftaligned
Number column headings are right-aligned
Default heading display: Uppercase
1-8
Arithmetic Expressions
Create expressions with number and date data by
using arithmetic operators.
Operator
+
Add
Subtract
Multiply
1-9
Description
Divide
1-10
Operator Precedence
1-11
1-12
Null Values
in Arithmetic Expressions
Arithmetic expressions containing a null value evaluate
to null.
SELECT last_name, 12*salary*commission_pct
FROM
employees;
1-13
1-14
1-15
Concatenation Operator
A concatenation operator:
Links columns or character strings to other
columns
Is represented by two vertical bars (||)
Creates a resultant column that is a character
expression
SELECT
FROM
last_name||job_id AS "Employees"
employees;
1-16
1-17
1-18
SELECT department_name ||
q'[, it's assigned Manager Id: ]'
|| manager_id
AS "Department and Manager"
FROM departments;
1-19
Duplicate Rows
The default display of queries is all rows, including
duplicate rows.
SELECT department_id
FROM
employees;
1-20
SQL statements
Internet
browser
iSQL*Plus
commands
Query results
Formatted report
Client
1-21
Oracle
server
SQL
statements
1-22
iSQL*Plus
An environment
Oracle-proprietary
Keywords can be
abbreviated.
Commands do not allow
manipulation of values in
the database.
Runs on a browser
Centrally loaded; does not
have to be implemented
on each machine
iSQL*Plus
commands
Overview of iSQL*Plus
After you log in to iSQL*Plus, you can:
Describe table structures
Enter, execute, and edit SQL statements
Save or append SQL statements to files
Execute or edit statements that are stored in saved
script files
1-23
Logging In to iSQL*Plus
From your browser environment:
1-24
iSQL*Plus Environment
8
1-25
1-26
DESCRIBE employees
1-27
1-28
1-29
1-30
D:\TEMP\emp_data.sql
3
1-31
1-32
1-33
2
3
1-34
1-35
Summary
In this lesson, you should have learned how to:
Write a SELECT statement that:
Returns all rows and columns from a table
Returns specified columns from a table
Uses column aliases to display more descriptive
column headings
1-36
Practice 1: Overview
This practice covers the following topics:
Selecting all data from different tables
Describing the structure of tables
Performing arithmetic calculations and specifying
column names
Using iSQL*Plus
1-37