Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
all labs.pdf
Скачиваний:
74
Добавлен:
25.02.2016
Размер:
2.04 Mб
Скачать

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

Objectives

Copyright © 2009, Oracle. All rights reserved.

Academy

 

 

 

 

 

Oracle

To extract data from the database, you need to use the SQL SELECT statement. However, you may

need to restrict the columns that are displayed. This lesson des ribes all the SQL statements that are needed to perform these actions. Further, you may want to create SELECT statements that can be

used more than once.

 

Only

 

&

Internal

 

Oracle

Use

 

 

Oracle Database 11g: SQL Fundamentals I 1 - 2

Lesson Agenda

Basic SELECT statement

Arithmetic expressions and NULL values in the SELECT statement

Column aliases

Use of concatenation operator, literal character strings, alternative quote operator, and the DISTINCT keyword

DESCRIBE command

 

Copyright © 2009, Oracle. All rights reserved.

Academy

 

 

 

 

Oracle

&

Only

 

 

Internal

 

 

 

 

Use

 

Oracle

 

 

 

Oracle Database 11g: SQL Fundamentals I 1 - 3

Copyright © 2009, Oracle. All rights reserved.
Capabilities of SQL SELECT Statements
Projection
Table 1
Table 1

Capabilities of SQL SELECT Statements

Selection

Table 1

Join

Table Academy2

Selection: Select the rows in a table that areOraclereturned by a query. Various criteria can be used to

A SELECT statement retrieves information from the database. With a SELECT statement, you can

use the following capabilities:

 

 

 

Projection: Select the columns in a table that are eturned by a query. Select as few or as many

 

of the columns as required.

 

 

Only

restrict the rows that are retrieved.

&

 

 

 

 

Internal

 

Joining: Bring together data th t is stored in different tables by specifying the link between

 

them. SQL joins are covered in more detail in the lesson titled “Displaying Data from Multiple

 

Tables.”

 

Use

 

 

 

 

 

Oracle

 

 

 

Oracle Database 11g: SQL Fundamentals I 1 - 4

Basic SELECT Statement

SELECT *|{[DISTINCT] column|expression [alias],...} FROM table;

SELECT identifies the columns to be displayed.

FROM identifies the table containing those columns.

Copyright © 2009, Oracle. All rights reserved.

Basic SELECT Statement

Academy

 

In its simplest form, a SELECT statement must include the fol owing:

• A SELECT clause, which specifies the columns to be displayed

 

• A FROM clause, which identifies the table containing the columns that are listed in the SELECT

clause

 

Oracle

In the syntax:

 

 

is a ist&of one or more columns

SELECT

 

*

 

selects all columnsOnly

DISTINCT

 

suppresses duplicates

column|expression

selects the named column or the expression

alias

 

gives the selected columns different headings

FROM table

Use

specifies the table containing the columns

 

Internal

Note: Throughout this course, the words keyword, clause, and statement are used as follows:

A keyword refers to an individual SQL element. For example, SELECT and FROM are keywords.

A clause is a part of a SQL statement.

For example, SELECT employee_id, last_name, and so on is a clause.

A statement is a combination of two or more clauses. For example, SELECT * FROM employees is a SQL statement.Oracle

Oracle Database 11g: SQL Fundamentals I 1 - 5

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]