- Shopping Bag ( 0 items )
Other sellers (Hardcover)
-
All (12) from $1.99
-
New (3) from $26.97
-
Used (9) from $1.99
More About This Textbook
Overview
Get Certified with Official Exam Prep Material from Oracle Press
Prepare to pass the Oracle Certified Professional Introduction to Oracle9i: SQL exam—a required exam for OCP DBA certification—using this Oracle Press study guide. Throughout each chapter, you'll find in-depth details on all the material covered on this challenging exam, followed by practice questions and chapter summaries to highlight what you've learned. Written for novices and experts alike, this book and CD-ROM package is the most comprehensive exam preparation tool available for this Oracle9i Certified Professional exam.
Featuring a logical methodology designed to reinforce learning, this exam guide offers
Required Exam for OCP DBA Certification
Book and CD-ROM include more than 300 interactive exam-based questions. CD-ROM contains interactive exams that simulate the actual OCP exams and include hotlinked questions, answers, and explanations.
Product Details
Related Subjects
Meet the Author
Jason Couchman (New York, NY) is an OCP-certified Oracle DBA and author of Oracle Certified Professional DBA Certification Exam Guide, Oracle Certified Professional Application Developer Exam Guide, Oracle Certified Professional DBO Certifica-tion Exam Guide, and Oracle8 Certified Professional DBA Practice Exams. He has led Oracle database projects with Fortune 500 corporations and presented topics at the North Carolina Oracle User Group. His articles on Internet and intranet development have been published internationally.
Read an Excerpt
Chapter 2: Limiting, Sorting, and Manipulating Return Data
In this chapter, you will learn about and demonstrate knowledge in the following areas:Restricting and Sorting Row Data
This section will cover the following areas related to restricting and sorting row data:Sorting Return Data with the order by Clause
Notice that Oracle does not return data requested in a particular order on any particular column, either numeric or alphabetical. According to the fundamentals of relational database theory, a table is by definition an unordered set of row data. That's fine for the ivory tower, but it's not always useful in real-world situations. Oracle enables you to order the output from select statements using the order by clause. This clause can impose a sort order on one or more columns in ascending or descending order in each of the columns specified. If more than one expression is specified for a sort order, then Oracle sorts in the order of data appearing in the first expression. If the first expression has duplicates, Oracle sorts in the order of data appearing in the second expression, and so on. The order by clause usually appears last in the Structured Query Language (SQL) statement, and the general syntax for the order by clause is to include both the clause and the column(s) or column alias(es) by which Oracle will order the results, each optionally followed by a special clause defining the direction of the order (asc for ascending and desc for descending). The default value is asc, and here is an example:An example of sorting output in descending order using the desc keyword is shown here:
The order by clause can be useful in simple reporting. It can be applied to columns that are NUMBER, text (VARCHAR2 and CHAR), and DATE datatypes. You can even use numbers to positionally indicate the column where Oracle should order the output from a statement. For example, if you issue a statement similar to the one in the following code block, the order for the output will be as shown (the number 2 indicates that the second column specified in the statement should be used to define the order in the output):
Here's an even more complex example:
For Review
1. Know how to put row data returned from a select statement in order and know the various sort orders (ascending and descending) that can be used with this option. Know also that Oracle can sort based on multiple columns.2. Be sure you understand both the positional and named ways to specify the column on which the sort order should be defined.
Exercises
1. Which of the choices below identifies the order by clause that produces the following output?A. order by empno asc
B. order by ename desc
C. order by hiredate asc
D. order by mgr desc
2. You are sorting data in a table in your select statement in descending order. The column you are sorting on contains NULL records. Where will the NULL records appear?
A. At the beginning of the list
B. At the end of the list
C. In the middle of the list
D. At the same location they are listed in the unordered table
3. Identify the default sort order used by Oracle when no sort order is specified:
______________________
4. The results from an SQL query are shown here:
Which of the following SQL statements could not have produced this output?
A. select deptno, dname, loc from dept order by 2 asc, 1 asc, 3 desc;
B. select deptno, dname, loc from dept order by 3 asc;
C. select deptno, dname, loc from dept order by 2 asc;
D. select deptno, dname, loc from dept order by 2 asc, 3 desc, 1 desc;...
Table of Contents