Section 2ORACLE Database Programming
Additional Review for Section 2
Name ______Date ______
S. Sherman, E. Williams Academy Instructors
Directions: answer each question.
- What are the two functions you should be able to accomplish after Section 2?
- What clause do you use to restrict the rows of data in a search?
- Where in the script is this clause placed?
- What three things does a WHERE clause consist of?
- What are the four comparisons a WHERE clause can complete?
- True or FALSE: WHERE job_id = SA_REP and WHERE job_id = Sa_Rep will return the same result.
- Of the three comparisons a WHERE clause can do, list each as well as any special marks that must accompany each.
- What can NOT be used in a WHERE clause?
- Write a WHERE clause for each of the ten (10) Comparison Conditions. Make sure that each clause you write is correct in terms of format and markings (such as quotation marks). You must use at least one date comparison, one numeric comparison, and one character comparison.
- Write today’s date using the Default Oracle Date format.
- Suppose you wanted to find all rows containing commission percentages of 15%, 20%, or 25%. Which Comparison Condition would you use?
- If you wanted to find the employees with the salary between $2000 and $4000, and you wrote the following select statement, it would fail. Give the two reasons why this statement is not accurate based on your desired results.
SELECT last_name, salary
FROM employees
WHERE salary BETWEEN 4001 and 2499;
- TRUE or False: The IN condition can be used with any data type (date, character, number).
- TRUE or False: When using the IN condition, you must use parenthesis ( ) to list comparison values.
- True or FALSE: When using the IN condition, you must use single quotes ( ‘ ) for numeric values.
- Which Comparison Condition allows you to search for a partial character string?
- What two things can be included in this search condition?
- True or False: Using literal characters to search for conditions is not case sensitive.
- True or FALSE: The following two scripts would return the exact same value:
SELECT last_name, hire_date
FROM employees
WHERE hire_date LIKE ‘%95’;
SELECT last_name, hire_date
FROM employees
WHERE hire_date BETWEEN ‘01-JAN-95’ AND ‘01-DEC-95’;
- What results would the following query return:
- SELECT last_name, hire_date
- FROM employees
- WHERE last_name LIKE ‘_i%’;
- What are the three Logical Conditions to restrict results?
- What does a Logical Condition do?
- When is a row returned when using Logical Conditions?
- What does the AND condition mean or return?
- What does the OR condition mean or return?
- What does the NOT condition mean or return?
- Where do you put a Logical Condition in a statement?
- How many conditions can you have in one WHERE clause?
- TRUE or False: When using the AND operator, all character string searches are case sensitive.
- True or FALSE: When using the AND operator, if the first condition is true and the second condition is false, the row will be returned.
- TRUE or False: When using the OR operator, if the first condition is true and the second condition is null, the row will be returned.
- Which operator is more likely to return rows, the AND operator or the OR operator?
- True or FALSE: You must have at least two conditions for the NOT operator to function properly.
- True or FALSE: The order of precedence is fixed and cannot be modified.
- What is the default order of rows when returning rows in a query?
- What clause do you use to sort rows returned?
- Where must this clause be placed?
- What can you specify as the sort condition?
- TRUE or False: If you do not use the ORDER BY clause, and you run the same query twice, you could get two different orders of rows returned.
- If you type this line:
ORDER BY hire_date
Which would come first, 24-MAR-03, 12-DEC-03, 29-JAN-04?
- If you typed this line:
ORDER BY commission_pct
Which would come first, .20, .15, null
- True or FALSE: You can use a column alias in the ORDER BY clause if you have not used an alias in the SELECT clause.
- What is the maximum number of columns you can sort data by?
- True or FALSE: You can only sort by columns listed in the SELECT clause of your query.
- True or FALSE: When sorting by more than one column, all columns need to be ascending or descending order, you cannot mix.
- What will the output be of this statement (be very specific):
SELECT last_name, salary * .1 AS raises
FROM employees
WHERE job_id LIKE '%SA\_%' ESCAPE '\'
AND raises >2000
ORDER BY raises DESC, job_id