Database Programming With SQL - MidTerm 2019

1. Columns in a database table contain data with the same _________:  Type (*)  Row  Key  Field 2. What command retr

Views 450 Downloads 7 File size 93KB

Report DMCA / Copyright

DOWNLOAD FILE

Recommend stories

Citation preview

1. Columns in a database table contain data with the same _________:  Type (*)  Row  Key  Field 2. What command retrieves data from the database?  DESCRIBE  SELECT (*)  INSERT  ALTER 3. All computers in the world speak the same languages, so you only need to learn one programming language - Oracle SQL. True or False?  True  False (*) 4. Evaluate this SELECT statement: SELECT (salary * raise_percent) raise FROM employees; If the RAISE_PERCENT column only contains null values, what will the statement return?  A null value or a zero depending on the value of the SALARY column  Only zeroes  A null value or a numeric value depending on the value of the SALARY column  Only null values (*) 5. What would you use in the SELECT clause to return all the columns in the table?  An asterisk (*) (*)  A plus sign (+)  The ALL keyword  A minus sign (-) 6. You need to combine the FIRST_NAME and LAST_NAME columns in the EMPLOYEES table and display the columns as a combined character string. Which operator should you use?  |  AND  || (*)  + 7. The following is a valid SQL SELECT statement. True or False? SELECT first_name || ' ' || last_name alias AS Employee_Name FROM employees:  True  False (*)

8. You want to retrieve a list of customers whose last names begin with the letters 'Fr' . Which symbol should you include in the WHERE clause of your SELECT statement to achieve the desired result?  *  ~  % (*)  # 9. To restrict the rows returned from an SQL Query, you should use the _____ clause:  SELECT  WHERE (*)  GROUP BY  CONDITION  All of the Above 10. The EMPLOYEES table contains these columns: LAST_NAME VARCHAR2(25) FIRST_NAME VARCHAR2(25) EMAIL VARCHAR2(50) You are writing a SELECT statement to retrieve the names of employees that have an email address. SELECT last_name||', '||first_name "Employee Name" FROM employees; Which WHERE clause should you use to complete this statement?  WHERE email IS NULL;  WHERE email = NULL;  WHERE email != NULL;  WHERE email IS NOT NULL; (*) 11. If you write queries using the BETWEEN operator, it does not matter in what order you enter the values, i.e. BETWEEN low value AND high value will give the same result as BETWEEN high value and low value. True or False?  True  False (*) 12. You need to change the default sort order of the ORDER BY clause so that the data is displayed in reverse alphabetical order. Which keyword should you include in the ORDER BY clause?  DESC (*)  ASC  CHANGE  SORT 13. The function COUNT is a single row function. True or False? True False (*)

14. What value will the following SQL statement return? SELECT employee_id FROM employees WHERE employee_id BETWEEN 100 AND 150 OR employee_id IN(119, 175, 205) AND (employee_id BETWEEN 150 AND 200);  100, 101, 102, 103, 104, 107, 124, 141, 142, 143, 144, 149 (*)  No rows will be returned  200, 201, 202, 203, 204, 205, 206  19 15. Evaluate this SELECT statement: SELECT last_name, first_name, salary FROM employees; How will the results of this query be sorted?  The database will display the rows in whatever order it finds it in the database, so no particular order. (*)  The results will be sorted ascending by LAST_NAME and FIRST_NAME only.  The results will be sorted ascending by the LAST_NAME column only.  The results will be sorted ascending by LAST_NAME, FIRST_NAME, and SALARY. 16. Round and Trunc cannot be used on Date datatypes. True or False?  True  False (*) 17. You issue this SQL statement: SELECT ROUND (1282.248, -2) FROM dual; What value does this statement produce?  1282.25  1200  1282  1300 (*) 18. The PRICE table contains this data: PRODUCT_ID MANUFACTURER_ID 86950 59604 You query the database and return the value 95. Which script did you use? SELECT SUBSTR(product_id, 3, 2) FROM price WHERE manufacturer_id = 59604; (*) SELECT SUBSTR(product_id, -1, 3) FROM price WHERE manufacturer_id = 59604;

SELECT LENGTH(product_id, 3, 2) FROM price WHERE manufacturer_id = 59604; SELECT TRIM(product_id, -3, 2) FROM price WHERE manufacturer_id = 59604; 19. What does the following SQL SELECT statement return? SELECT UPPER( SUBSTR('Database Programming', INSTR('Database Programming','P'),20)) FROM dual;  Database  PROGRAMMING (*)  DATABASE  Programming 20. Which statement about group functions is true?  COALESCE, but not NVL and NVL2, can be used with group functions to replace null values.  NVL and NVL2, but not COALESCE, can be used with group functions to replace null values.  NVL and COALESCE, but not NVL2, can be used with group functions to replace null values.  NVL, NVL2, and COALESCE can be used with group functions to replace null values. (*) 21. The STYLES table contains this data:

Evaluate this SELECT statement: SELECT style_id, style_name, category, cost FROM styles WHERE style_name LIKE 'SANDAL' AND NVL(cost, 0) < 15.00 ORDER BY category, cost; Which result will the query provide?

STYLE_ID 968950 895840 758960

STYLE_NAME SANDAL SANDAL SANDAL

CATEGORY 85909 85940 86979

COST 10.00 12.00

22. Which statement will return a listing of last names, salaries, and a rating of 'Low', 'Medium', 'Good' or 'Excellent' depending on the salary value? SELECT last_name,salary, (RATING WHEN salary