Database Programming Section 4 Quiz
Section 4 Quiz
(Answer all questions in this section)
1. Which of the following Date Functions will add calendar
months to a date? Mark for Review
(1) Points
NEXT_MONTH
MONTHS + Date
Months + Calendar (Month)
ADD_MONTHS (*)
2. Which SELECT statement will return a numeric value?
Mark for Review
(1) Points
SELECT SYSDATE - 7
FROM employees;
SELECT (SYSDATE - hire_date) / 7
FROM employees;
(*)
SELECT SYSDATE + 600 / 24
FROM employees;
SELECT ROUND(hire_date, DAY)
FROM employees;
3. You need to display the number of months between
today's date and each employee's hiredate. Which function should you
use? Mark for Review
(1) Points
ADD_MONTHS
BETWEEN
ROUND
MONTHS_BETWEEN (*)
4. Which function would you use to return the current
database server date and time? Mark for Review
(1) Points
SYSDATE (*)
DATETIME
CURRENTDATE
5. If hire_date has a value of '03-Jul-2003', then what is the
output from this code?
SELECT ROUND(hire_date, 'Year') FROM employees; Mark for
Review
(1) Points
01-Jan-2004 (*)
01-Aug-2003
01-Jul-2003
01-Jan-2003
6. Evaluate this function: MOD (25, 2) Which value is
returned? Mark for Review
(1) Points
25
1 (*)
7. ROUND and TRUNC functions can be used with which of
the following Datatypes? Mark for Review
(1) Points
Dates and numbers (*)
Dates and characters
Numbers and characters
None of the above
8. Which number function may be used to determine if a
value is odd or even? Mark for Review
(1) Points
TRUNC
MOD (*)
ROUND
9. Which script displays '01-May-2004' when the
HIRE_DATE value is '20-May-2004'? Mark for Review
(1) Points
SELECT TRUNC(hire_date, 'MONTH')
FROM employees;
(*)
SELECT ROUND(hire_date, 'MONTH')
FROM employees;
SELECT ROUND(hire_date, 'MON')
FROM employees;
SELECT TRUNC(hire_date, 'MI')
FROM employees;
10. The answer to the following script is 456. True or False?
SELECT TRUNC(ROUND(456.98))
FROM dual; Mark for Review
(1) Points
True
False (*)
(Answer all questions in this section)
11. You need to display each employee's name in all
uppercase letters. Which function should you use? Mark for
Review
(1) Points
UPPER (*)
UCASE
CASE
TOUPPER
12. Identify the output from the following SQL statement:
SELECT RPAD('SQL',6, '*')
FROM DUAL; Mark for Review
(1) Points
***SQL
SQL*** (*)
SQL******
******SQL
13. Which query would return a user password combining
the ID of an employee and the first 4 digits of the last name? Mark
for Review
(1) Points
SELECT CONCAT (employee_id, INSTR(last_name,1,4))
AS "User Passwords"
FROM employees
SELECT CONCAT (employee_id, SUBSTR(last_name,4,1))
AS "User Passwords"
FROM employees
SELECT CONCAT (employee_id, SUBSTR(last_name,1,4))
AS "User Passwords"
FROM employees
(*)
SELECT CONCAT (employee_id, INSTR(last_name,4,1))
AS "User Passwords"
FROM employees
14. What will the following SQL statemtent display?
SELECT last_name, LPAD(salary, 15, '$')SALARY
FROM employees; Mark for Review
(1) Points
The query will result in an error: "ORA-00923: FROM keyword not
found where expected."
The last name of employees that have a salary that includes a $ in the
value, size of 15 and the column labeled SALARY.
The last name and salary for all employees with the format of the
salary 15 characters long, left-padded with the $ and the column
labeled SALARY. (*)
The last name and the format of the salary limited to 15 digits to the
left of the decimal and the column labeled SALARY.
15. Which of the following SQL statements would correctly
return a song title identified in the database as "All These Years"?
Mark for Review
(1) Points
WHERE title CONTAINS 'Years';
WHERE title LIKE INITCAP('%all these years'); (*)
WHERE title IN('All','These','Years');
WHERE title LIKE LOWER('all these years');