
- •Objectivesj i
- •Capabilitiesili i of SQL SELECT
- •Basicic SELECT Statement
- •Writingi i SQL Statements
- •Selectingl i Allll Columnsl
- •Selectingl i Specifici ic Columnsl
- •Columnl Headingi Defaultsl
- •Arithmetici ic Expressionsi
- •Usingi Arithmetici ic Operators
- •Operator Precedence
- •Operator Precedence
- •Usingi Parentheses
- •Definingi i a Nullll Valuel
- •Nullll Valuesl inin Arithmetici ic Expressionsi
- •Definingi i a Columnl Aliasli
- •Usingi Columnl Aliasesli
- •Concatenationi Operator
- •Usingi the Concatenationi
- •Literali l Character Stringsi
- •Usingi Literali l Character Stringsi
- •Duplicateli Rows
- •Eliminatingli i i Duplicateli Rows
- •SQL and SQL*Plusl InteractionI i
- •SQL Statements Versus
- •Overviewie of SQL*Plusl
- •Loggingi InIn to SQL*Plusl
- •Displayingi l i Tablele Structure
- •Displayingi l i Tablele Structure
- •SQL*Plusl Editingi i Commands
- •SQL*Plusl Editingi i Commands
- •SQL*Plusl Fileile Commands
- •Summary
- •Practicei Overviewie

Duplicateli Rows
The default display of queries is all rows, including duplicate rows.
SQL> SELECT deptno 2 FROM emp;
DEPTNO
---------
10
30
10
20
...
14 rows selected.
1-22

Eliminatingli i i Duplicateli Rows
Eliminate duplicate rows by using the DISTINCT keyword in the SELECT clause.
SQL> SELECT DISTINCT deptno 2 FROM emp;
DEPTNO
---------
10
20
30
1-23

SQL and SQL*Plusl InteractionI i
SQL Statements
SQL*Plus |
Buffer |
SQL Statements
Server
SQL*Plus |
Query Results |
Commands |
|
Formatted Report
1-24

SQL Statements Versus
SQL*Plusl Commands
SQL
•A language
•ANSI standard
•Keyword cannot be abbreviated
•Statements manipulate data and table definitions in the database
SQL |
statements |
SQL |
SQL*Plus
•An environment
•Oracle proprietary
•Keywords can be abbreviated
•Commands do not allow manipulation of values in the database
SQL*Plus |
commands |
1-25

Overviewie of SQL*Plusl
•• Log inin toto SQL*Plus* l ..
•• Describeri thet tablet le structuretr t re..
•• Editit yourr SQL statementt t t..
•• Executete SQL fromfr SQL*Plus* l ..
•• Save SQL statementst t ts toto filesfil and append SQL statementst t ts toto filesfil ..
•• Executete saved filesfil ..
•• Load commands fromfr filefile toto bufferff r toto editit..
1-26

Loggingi InIn to SQL*Plusl
•From Windows environment:
•From command line:
sqlplus [username[/password |
[@database]]] |
1-27

Displayingi l i Tablele Structure
Use the SQL*Plus DESCRIBE command to display the structure of a table.
DESC[RIBE] tablename
1-28

Displayingi l i Tablele Structure
SQL> DESCRIBE dept
|
|
|
|
|
|
Name |
Null? |
Type |
|
|
----------------- |
-------- |
------------ |
|
|
DEPTNO |
NOT NULL NUMBER(2) |
|
|
|
DNAME |
|
VARCHAR2(14) |
|
|
LOC |
|
VARCHAR2(13) |
|
|
|
|
|
|
1-29

SQL*Plusl Editingi i Commands
•• A[PPEND][ ] textt t
•• C[HANGE][ ] // oldld // new
•• C[HANGE][ ] // textt t //
•• CL[EAR][ ] BUFF[ER][ ]
•• DEL
•• DEL n
•• DEL m n
1-30

SQL*Plusl Editingi i Commands
•• I[NPUT]I[ ]
•• I[NPUT]I[ ] textt t
•• L[IST][I ]
•• L[IST][I ] n
•• L[IST][I ] m n
•• R[UN][ ]
•• n
•• n textt t
•• 0 textt t
1-31