Вы находитесь на странице: 1из 17

N

ExamEssentials

CH 1 Restricting and Sorting Data


Understand the operators. Know the various operators that can be used inqueries.The
parentheses around an expression change the precedence of the operators.

Understand the ORDER BY clause. The ORDER BY clause is used to sort the result
set from a query. You can specify ascending order or descending order for the sort.
Ascending order is the default. Also know that column alias names can be used in
the ORDER BY clause. You can also specify columns by their position.
Know how to specify string literals using the operator.
Know the order of clauses in the SELECT statement. The SELECT statement
must have a FROM clause. The WHERE clause, if it exists, should follow the FROM
clause and precede the ORDER BY clause.
Literal Character Strings
-Date and character literal values must be enclosed within single quotation marks.
SELECT last_name ||' is a '||job_id
AS "Employee Details"
FROM employees;
Know the use of the DUAL table. The DUAL table is a dummy table in Oracle
with one column and one row. This table is commonly used to get the values of
system variables such as SYSDATE or USER.
Know the characters used for pattern matching. The % character is used to
match zero or more characters .The _ character is used to match one, and only one,
character .The SQL operator used with a pattern-matching character is LIKE.
Know the sort order of NULL values inquiries with ORDER BY clause. By
default, in an ascending-orders or the NULL values appear at the bottom of the
result set; that is, NULLs are sorted higher. For descending-order sorts, NULL
values appear at the top of the result setagain, NULL values are sorted higher.

Page 1 of 17

ExamEssentials

CH 2 Using Single-Row Functions to Customize Output


Understand where single-row functions can be used. Single-row functions can
be used in the SELECT, WHERE, and ORDER B Y clauses of SELECT statements.

Know the effect sthat NULL values can have on arithmetic and other functions.
Any arithmetic operation on a NULL results in a NULL. This is true of most
functions as well. Use the NVL, NVL2, and COALESCE functions to deal with NULLs.
Review the character-manipulation functions. Understand the arguments and
the result Of using character-manipulation functions such as INSTR, SUBSTR,
REPLACE, and TRANSLATE.

Page 2 of 17

ExamEssentials

Understand the numeric functions. Know the effects of using TRUNC and ROUND
with-nas the second argument. Also practice using LENGTH and INSTR, which
return a numeric result, inside SUBSTR and other character functions.

Know how date arithmetic works. When adding or subtracting numeric values
from a DATE datatype, whole numbers represent days. Also, the date/time
intervals INTERVAL YEAR TO MONTH and INTERVAL DAY TO SECOND can be added
or subtracted from date/time datatypes. You need to know how to interpret and
create expressions that add intervals to or subtract intervals from dates.

Page 3 of 17

ExamEssentials

Know the data types for the various date/time functions. Oracle has many
date/time functions to support the date/time datatypes. You need to know the
return datatypes for these functions. SYSDATE and CURRENT_DATE return a DATE
datatype. CURRENT_TIMESTAMP and SYSTIMESTAMP return a TIMESTAMP WITH
TIMEZONE datatype. LOCALTIMESTAMP returns a TIMESTAMP datatype.

Understand the use of the DECODE function. DECODE acts like a case statement in
C,Pascal, or Ada.Learn how this function works and how to use it.

Page 4 of 17

ExamEssentials

CH 3 Using Conversion Functions and Conditional Expressions


Know the format models for converting dates to/from character strings. In
practice, you can simply lookup format codes in a reference .For the certification
exam, you must have them memorized.

SQL> SELECT TO_DATE('01/01/05', 'DD/MM/YY') FROM DUAL;


TO_DATE('
--------01-JAN-05 // output format is determined by NLS_DATE_FORMAT//

Page 5 of 17

ExamEssentials

TO_CHAR function.
The TO_CHAR function converts a date or number to a TEXT expression in a
specified format. This function is typically used to format output data.
Note: Output format is specified in the expression itself.

TO_NUMBER function.
The TO_NUMBER function converts a formatted TEXT expression to a number.
SELECT TO_NUMBER('$1210.73', 'L9999.99') FROM DUAL
RESULT= 1210.73

Page 6 of 17

ExamEssentials

CH 3 Reporting Aggregated Data Using the Group Functions


It is important to understand the concept to grouping data, where GROUP BY
and HAVING clauses can be used, and the rules associated with using these
clauses.
Except for COUNT(*), group functions ignore NULLs. Programmer written
functions cannot be used as group functions. COUNT, SUM, and AVG are the
most commonly used group functions. When using group functions or
aggregate functions in a query,the columns that do not have any aggregate
function applied to them must appear in the GROUP BY clause of the query.
The HAVING clause is used to filter out data after the aggregates are calculated.
Group func tions cannot be used in the WHERE clause.
You can create super aggregates usingthe CUBE and ROLLUP modifiers in the
GROUP BY clause.

ExamEssentials
Understand the usage of DISTINCT in group functions. When
DISTINCT is specified, only one of each non-NULL value is applied to the
function. To apply all non-NULL values, the key word ALL should be used.
COUNT
COUNT(expr) returns the number of rows with non-null values for the expr.
COUNT(DISTINCT expr) returns the number of distinct non-null values of the expr.
SELECT COUNT(DISTINCT department_id)
FROM employees;

Know where group functions can be used. Group functions can be used in
GROUP BY, ORDER BY,and HAVING clauses.They cannot be used in WHERE
clauses.
Page 7 of 17

ExamEssentials

Know how MIN and MAX sort date and character data. Older dates
evaluate to lower values, while newer dates evaluate to higher values.
Character data, even if it contains numbers, is sorted according to the
NLS_SORT specification.
Know which expressions in a SELECT list must appear in a GROUP BY
clause. If any grouping is performed, all non group function expressions
and non constant expressions must appear in the GROUP BY clause.
Know the order of precedence for evaluating nested functions. You
may need to evaluate an expression containing nested functions. Make
sure you understand the left-to-right order of precedence used to evaluate
these expressions.

Page 8 of 17

ExamEssentials

CH 4 Displaying Data from Multiple Tables


If the join condition uses the equality operator (= or IN),it is known as an
equality join. If any other operator is used to join the tables, it is a non
equality join. If you do not specify any join condition between the tables,the
result will be a Cartesian product: each row from the first table joined to
every row in the second table. To avoid Cartesian joins, there should be at
least n-1join conditions in the WHERE clause when there are n tables in the
FROM clause. A table can be joined to itself. If you want to select the results
from a table, even if there are no corresponding rows in the joined table, you
can use the outer join operator:
A sub query is a query within a query. Writing sub queries is a powerful
way to manipulate data. You can write single-row and multiple-row
subqueries. Single-row sub queries must return zero or one row; multiplerow sub queries return zero or more rows.IN and EXISTS are the most
commonly used sub query operators. Sub queries can appear in the WHERE
clause or in the FROM clause. They can also replace table names in SELECT,
DELETE, INSERT, and UPDATE statements. Subqueries that return one row
and one column result are known as scalar sub queries. Scalar sub queries
can be used in most places where you would use an expression.
ExamEssentials
Understand joins. Make sure you know the different types of joins.
Understand the difference between natural, cross, simple, complex, and
outer joins.
Be sure of the join syntax. Spend time practicing each type of join using
the ANSI syntax. Understand the restrictions of using each ANSI keyword
in the JOIN and their implied column-naming conventions

Page 9 of 17

ExamEssentials

CH 5 Using Subqueries to Solve Queries


Know how to write sub queries. Understand the use and flexibility of sub
queries. Practice using scalar sub queries and correlated sub queries.
Understand the use of the ORDER BY clause in the sub queries. You can
use the ORDER BY clause in all sub queries, except the sub queries
appearing in the WHERE clause of the query. You can use the GROUP BY
clause in the sub queries.
CH 6 SET OPERATORS
Know the set operators. Understand the set operators that can be
used in compound queries. Know the difference between the UNION and
UNION ALL operators.
Understand where you can specify the ORDER BY clause when using set
operators. When using set operators to join two or more queries, the
ORDER BY clause can appear only at the very end of the query. You can
specify the column names as they appear in the top query or use positional
notation.

Page 10 of 17

ExamEssentials

CH 7 Manipulating Data
Know the syntax for the INSERT statement. When a subquery is used
to add rows to a table, the VALUES clause should not be used.
Practice UPDATE statements The UPDATE statement can update multiple
columns in the same row using a subquery. Multiple subqueries can also
be used to update columns in a single row.
Understand what will begin and end a transaction. A transaction will
begin with an INSERT, UPDATE, DELETE, MERGE, or SELECT FOR UPDATE
statement. A COMMIT or ROLLBACK will end a transaction. A DDL
statement can also end a transaction.
Know how to set and roll back to save points. Savepoints are set with
the SAVEPOINT statement. Data changes made after a savepoint are undone
when a ROLLBACK TO SAVEPOINT statement is executed. ROLLBACK TO
SAVEPOINT is a partial undo operation.
Understand the scope of data changes and consistency. Statement- level
consistency is automatic and will ensure that each SELECT will see an image
of the database consistent with the beginning of the statements execution.
Transaction-level consistency will ensure that all SELECT statements within
a transaction will see an image of the database consistent with the
beginning of the transaction
.

Page 11 of 17

ExamEssentials

CH 8 Using DDL Statements to Create and Manage Tables


Understand data types. Know each data types limitations and
accepted values. Concentrate on the new TIMESTAMP and INTERVAL
datatypes.
Know how date arithmetic works. Know the resulting data type of date
arithmetic, especially between INTERVAL and DATE datatypes.
Know how to modify column characteristics. Understand how to change
data types, add and modify constraints, and make other modifications.
Understand the rules associated with changing data type definitions of
columns with rows in a table. When the table is not empty, you can change
a datatype only from CHAR to VARCHAR2, and vice versa. Reducing the
length is allowed only if the existing data fits in the new length specified.
Understand the DEFAULT clause on the column definition. The DEFAULT
clause provides a value for the column if the INSERT statement omits a
value for the column. When modifying a column to have default values, the
existing rows with NULL values in the table are not updated with the default
value.
Know the actions permitted on read-only tables Understand the various
actions that are permitted on a read-only table. Any operation that changes
the data in the table is not allowed on a read-only table. Most DDL
statements are allowed, including DROP TABLE.
Understand constraints. Know the difference between a primary key
and a unique key constraint,and understand how to use a nonunique
index for primary/unique keys.

Page 12 of 17

ExamEssentials

Know how a constraint can be defined. You can use the CREATE TABLE or
ALTER TABLE statement to define a constraint on the table.

Page 13 of 17

ExamEssentials

Ch 9 Creating Other Schema Objects


Understand how join views work. Know the restrictions on the
columns that can be updated in a join view.
Understand how constraints are used with views. Understand the type
of constraints that can be defined on a table.
Understand how in line views are used. In line views are subqueries
used in the FROM clause. These subqueries can have an ORDER BY clause.
Know how to change the definition of a view. The CREATE OR REPLACE
VIEW statement is used to change the definition of the view. The ALTER VIEW
statement is used to recompile a view or to manage constraints on a view.

Know the precise syntax for obtaining sequence values. You should
understand how to use sequence_name. NEXTVAL and
sequence_name. CURRVAL to obtain the next and most recently
generated number from a sequence.

Page 14 of 17

ExamEssentials

Understand when indexes degrade performance.


EXPLAINATION
An index creates an entry for each value that appears in the indexed columns.
By default, Oracle creates B-tree indexes
Bitmap and B-Tree index maps column(S) data to ROWID
Fetches a row by using ROWID instead of a full table scan.
Indexes improve SELECT, UPDATE AND DELETE operations.
An index can be used is a leading subset of the indexed column appears in the
SELECT or WHERE clause.

Know that indexes degrade the performance of DML operations(INSERT,


UPDATE, and DELETE).
Automatically: A unique index is created automatically when you define a
PRIMARY KEY or UNIQUE constraint in a table definition.

Page 15 of 17

ExamEssentials

B-Tree Index
-Suited for high cardinality columns (columns having many distinct values)
-Excels at servicing simple queries( not having many OR & AND statements )
Bitmap Index
-Suited for high cardinality columns, male/femal, direction N , S , E, W.

MARITAL_STATUS, REGION and GENDER,are all low-cardinality columns. There


are only three possible values for marital status and region and two possible values for
gender
Function-Based Indexes.

A function-based index is an index based on expressions.

The index expression is built from table columns, constants, SQL functions,
and user-defined functions.

CREATE INDEX with CREATE TABLE Statement


CREATE TABLE NEW_EMP
(employee_id NUMBER(6)
PRIMARY KEY USING INDEX

Page 16 of 17

ExamEssentials

(CREATE INDEX emp_id_idx ON


NEW_EMP(employee_id)),
first_name VARCHAR2(20),
last_name VARCHAR2(25));
SELECT INDEX_NAME, TABLE_NAME
FROM USER_INDEXES
WHERE TABLE_NAME = 'NEW_EMP';

Know when a bitmap index is more appropriate than a B-treeindex.


Bitmap indexes
Work best on low-to medium cardinality columns where row-level locking is
not needed. In contrast, B-tree indexes work best on high-to mediumcardinality columns and do support row-level locking.
Know how Oracle will resolve table references. Oracle will first search for
a table or view that matches the referenced name. If no table or view is
found, private synonyms are then examined. Finally, public synonyms are
examined. If no matching name is found, Oracle will raise an exception.

Altering sequences (solution for the above pitfalls)


Note: You cannot directly alter the sequence and change its NEXTVAL. Instead, you
can take one of the following approaches:
Drop and re-create it(invalidating all dependent objects and losing the grants).
Select NEXTVAL from it enough times to bring the sequence up to a desired value.
Alter the sequence by changing the INCREMENT BY value to a large number, select
NEXTVAL from the sequence to make it increment by the large number, then alter
the INCREMENT BY value back down to the original small value.

Page 17 of 17

Вам также может понравиться