Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Semestr2 / 1 - Oracle / 1-Select+functions.ppt
Скачиваний:
15
Добавлен:
12.05.2015
Размер:
254.46 Кб
Скачать

1

Writing Basic

SQL Statements

Objectivesj i

After completing this lesson, you should be able to do the following:

Listi t thet capabilitiesiliti off SQL SELECT statementst t ts

Executete a basicic SELECT statementt t t

Differentiateiff r ti te betweent SQL statementst t ts and SQL*Plus* l commands

1-2

Capabilitiesili i of SQL SELECT

Statements

Selection

Projection

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Table 1

Join

Table 1

Table 1

Table 2

1-3

Basicic SELECT Statement

 

 

 

 

 

SELECT

[DISTINCT] {*, column [alias],...}

 

 

FROM

table;

 

 

 

 

 

 

 

 

 

SELECT identifiesi tifi whatt columnsl

FROM identifiesi tifi whichi tablet le

1-4

Writingi i SQL Statements

SQL statementst t ts arere nott case sensitiveiti ..

SQL statementst t ts can be on one orr morere linesli ..

Keywordsr cannott be abbreviatedr i t orr splitlit acrossr linesli ..

Clausesl arere usuallylly placedl on separater te linesli ..

Tabs and indentsi ts arere used toto enhance readabilityr ility..

1-5

Selectingl i Allll Columnsl

SQL> SELECT *

2 FROM dept;

 

 

 

 

 

 

DEPTNO

DNAME

LOC

 

 

---------

--------------

-------------

 

 

10

ACCOUNTING

NEW YORK

 

 

20

RESEARCH

DALLAS

 

 

30

SALES

CHICAGO

 

 

40

OPERATIONS

BOSTON

 

 

 

 

 

 

1-6

Selectingl i Specifici ic Columnsl

SQL> SELECT deptno, loc 2 FROM dept;

 

 

 

 

 

DEPTNO

LOC

 

 

---------

-------------

 

 

10

NEW YORK

 

 

20

DALLAS

 

 

30

CHICAGO

 

 

40

BOSTON

 

 

 

 

 

1-7

Columnl Headingi Defaultsl

Defaultf lt justificationj tifi ti

Left:ft: Datete and characterr t r datata

Right:i t: Numericric datata

Defaultf lt display:i l : Uppercaser

1-8

Arithmetici ic Expressionsi

Create expressions on NUMBER and DATE data by using arithmetic operators.

Operator Description

+Add

-Subtract

*Multiply

/Divide

1-9

Usingi Arithmetici ic Operators

SQL> SELECT ename, sal, sal+300 2 FROM emp;

ENAME

SAL

SAL+300

----------

--------- ---------

KING

5000

5300

BLAKE

2850

3150

CLARK

2450

2750

JONES

2975

3275

MARTIN

1250

1550

ALLEN

1600

1900

...

 

 

14 rows selected.

1-10

Operator Precedence

*

/

+

_

Multiplicationlti li ti and divisioni i i taket priorityri rity overr additioniti and subtractiontr ti ..

Operatorsr t rs off thet same priorityri rity arere evaluatedl t fromfr leftl ft toto rightri t..

Parenthesesr t arere used toto forcef r prioritizedri riti evaluationl ti and toto clarifyl rify statementst t ts..

1-11

Соседние файлы в папке 1 - Oracle