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 SQL*Plus
commands
Lesson Aim
To extract data from the database. you need to use the structured query
language (SQL) SELECT statement You may need to restrict the columns
that are displayed. This lesson describes all Ihe SQL statements that you need
to perform these actions.
You may want to create SELECT statements that can be used time and time
again. Tins lesson also covers the use of SQL*Plus commands to execute
SQL statements
2
, Capabilities of SQL SELECT
Statements
Selection Projection
Table
2
Table
1
Capabilities of SQL SELECT Statements
A SELECT statement retrieves information from the database. Using a
SELECT statement, you can do the following:
Selection: You can use the selection capability in SQL to choose the rows in
a table that you want returned by a query. You can use various criteria to
selectively restrict the rows that you see.
Projection: You can use the projection capability in SQL to choose the
columns in a table that you want returned by your query. You can choose as
few or as many columns of the table as you require.
Join: You can use the join capability in SQL to bring together data that is
stored in different tables by creating a link through a column that both the
tables share. You will learn more about joins in a later lesson.
•SELECT identifies what columns.
•FROM identifies which table.
Basic SELECT Statement
In its simplest form, a SELECT statement must include the following
A SELECT clause, which specifies the columns to be displayed.
A FROM clause, which specifies the table containing the columns
listed in the SELECT clause.
In the syntax:
SELECT is a list of one or more columns.
DISTINCT suppresses duplicates.
* selects all columns
column selects the named column.
alias gives selected columns different headings.
FROM table specifies the table containing the columns.
Note: Throughout this course, the words keyword, clause, and statement are
used.
A keyword refers to an individual SQL element. For example, SELECT and
FROM are keywords.
A clause is a part of an SQL statement. For example. SELECT empno,
ename, … is a clause.
A statement is a combination of two or more clauses. For example. SELECT
* FROM emp is a SQL statement.
4
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller abdalkareemadel93. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $14.45. You're not tied to anything after your purchase.