DP 1 3 SG

Download as pdf or txt
Download as pdf or txt
You are on page 1of 31

Release Date: August, 2015

Updates:
3
4
5
SELECT clause: Specifies the columns to be displayed (or use * symbol to display all columns).
FROM clause: Specifies the table containing the column(s) listed in the select clause.
Column: An implementation of an attribute or relationship in a table.

6
The following SQL style conventions are used throughout this course:
SQL Keywords in UPPERCASE – e.g. SELECT, FROM, WHERE.
Column and table names in lower case – e.g. first_name, employees.
Each clause on a new line – e.g.
SELECT last_name
FROM employees
WHERE employee_id = 101;

7
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.
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 restrict the rows that you see

8
The SELECT clause determines Projection.
The WHERE clause determines Selection.

The execution of this query would result in the display of the salary column for any employees with the
last_name Smith.

9
Sometimes doing a SELECT * FROM table can take a long time to return the data. It all depends on the
number of rows stored in that particular table. Remember, Oracle tables can store millions of rows of data.

10
All examples on the slides have a semicolon after each statement. Oracle Application Express does not
require this syntax, but other Oracle SQL Interfaces do, so we have included them in the courseware.

11
12
13
Arithmetic expression: an expression that results in a numeric value.

14
Arithmetic operator: A symbol used to perform an operation on some values

15
16
17
18
The example on the left uses Operator Precedence to determine the order in which the operations are
performed. As * (multiplication) has higher precedence, the salary is first multiplied by 12, then 100 is
added to the result of the multiplication. So for employee King (salary 24000), 12*24000 is calculated =
288000, then 100 is added to give the answer 288100.
The example on the right uses parenthesis to force the addition to be carried out first, the result of the
addition is then multiplied by 12. So King has 24000+100 = 24100, this is then multiplied by 12 to give the
answer 289200.

19
NULL: A value that is unavailable, unassigned, unknown, or inapplicable .

20
NULL: A value that is unavailable, unassigned, unknown, or inapplicable .

21
22
In the example, a row with a null value in the commission_pct column will return a null value for the
salary*commission_pct column in this query.

NULL values are displayed in APEX using the – (dash) symbol.

23
Column alias: renames a column heading for display purposes. The original column name in the table
remains unchanged.

24
25
Double quotation marks are required for aliases longer than one word or when the format of the alias is
anything other than the default uppercase name (e.g., Department Name, or department, or dept.)

The first example uses the AS keyword, but has no "double quotes ", so the aliases are displayed in the
default UPPER case.
The second example omits AS, but as the intended alias is more than one word, uses the double quotes.
Using the optional AS keyword makes SQL statements easier to read.

26
27
28
29
30

You might also like