UJIAN SQL MODEL SOAL D 1 Evaluate this

  • Slides: 27
Download presentation
UJIAN SQL MODEL SOAL D

UJIAN SQL MODEL SOAL D

1. Evaluate this SQL statement : SELECT c. customer_id, o. order_date, p. product_name FROM

1. Evaluate this SQL statement : SELECT c. customer_id, o. order_date, p. product_name FROM customer c, curr_order o, product p WHERE customer_id = curr_order. customer_id AND o. product_id = p. product_id ORDER BY o. order_amount; This statement fails when executed. Which change will correct the problem? a. b. c. d. e. Use the table name in the ORDER BY clause. Remove the table aliases from the WHERE clause. Include the ORDER_AMOUNT column in the SELECT list. Use the table aliases instead of the table names in the WHERE clause. Remove the table alias from the ORDER BY clauses and use only the column name.

2. You need to create user Susan and allow this user to create and

2. You need to create user Susan and allow this user to create and drop tables in any schema. She should be able to create procedures and sequences only in her schema. Which script should you use to achieve these result? a. b. c. d. CREATE USER susan IDENTIFIED BY sue 123; GRANT CREATE SESSION, CREATE ANY TABLE, DROP ANY TABLE, CREATE SEQUENCE, CREATE PROCEDURE TO susan/ CREATE USER susan IDENTIFIED BY sue 123; GRANT CREATE SESSION, DROP ANY TABLE, CREATE SEQUENCE, CREATE PROCEDURE TO susan/ CREATE USER susan IDENTIFIED BY sue 123; GRANT CREATE TABLE, DROP TABLE, CREATE SEQUENCE, CREATE PROCEDURE TO susan/ CREATE USER susan IDENTIFIED BY sue 123; GRANT DROP ANY TABLE, CREATE SEQUENCE, CREATE PROCEDURE TO susan/

3. Seniority is based on the number of years a student has been enrolled

3. Seniority is based on the number of years a student has been enrolled at the university. You must create a report that displays each student’s name, id number, and the number of years enrolled. The years enrolled must be rounded to a whole number, based on the number of months from the date enrolled until today. which statements produces the required result ? a. b. c. d. e. SELECT first_name||’, ’||last_name “Student Name, id ”id”, enroll_date, TRUNC(SYSDATE, ’YY’) – TRUNC(enroll_date, ’YY’) “Seniority” FROM student; SELECT first_name||’, ’||last_name “Student Name, id ”id”, enroll_date, ROUND(MONTHS_BETWEEN(SYSDATE, enroll_date)/12) “Seniority” FROM student SELECT first_name||’, ’||last_name “Student Name”, id ”id”, enroll_date, ROUND(SYSDATE) – ROUND(enroll_date) “Seniority” FROM student; SELECT first_name||’, ’||last_name “Student Name, id ”id”, enroll_date, (ROUND((SYSDATE) – ROUND(enroll_date)) /12 “Seniority” FROM student

4. The EVENT table contains these columns: EVENT_ID NUMBER EVENT_NAME VARCHAR 2(30) EVENT_DESC VARCHAR

4. The EVENT table contains these columns: EVENT_ID NUMBER EVENT_NAME VARCHAR 2(30) EVENT_DESC VARCHAR 2(100) EVENT_TYPE NUMBER LOCATION_ID NUMBER You have been asked to provide a report of the number of different event types at each location. Which SELECT statement will produce the desired result? a. b. c. d. e. SELECT UNIQUE(location_id), COUNT(event_type) FROM event GROUP BY location_id; SELECT location_id, COUNT(DISTINCT event_type) FROM event GROUP BY location_id; SELECT location_id, MAX(DISTINCT event_type) FROM event GROUP BY location_id SELECT DISTINCT(event_type) FROM event GROUP BY location_id; SELECT COUNT(*), DISTINCT(location_id) FROM event;

5. Evaluate this SQL statement: SELECT supplier_id, AVG(cost) FROM product WHERE AVG(list_price) > 60.

5. Evaluate this SQL statement: SELECT supplier_id, AVG(cost) FROM product WHERE AVG(list_price) > 60. 00 GROUP BY supplier_id ORDER BY AVG(cost) DESC; Which clause will cause an error? a. SELECT b. ORDER BY c. WHERE d. GROUP BY

6. The ACCOUNT table contains these colums: ACCOUNT_ID NUMBER(12), NEW_PURCHASES NUMBER PREV_BALANCE NUMBER(72), FINANCE_CHARGE

6. The ACCOUNT table contains these colums: ACCOUNT_ID NUMBER(12), NEW_PURCHASES NUMBER PREV_BALANCE NUMBER(72), FINANCE_CHARGE NUMBER(7, 2) PAYMENTS NUMBER(7, 2) You created the ACCOUNT_ID_SEQ sequence to generate sequential values for the ACCOUNT_ID column. You issue this statement: ALTER TABLE account MODIFY (finace_charge NUMBER(8, 2)); Which statement about the ACCOUNT_ID_SEQ sequence is true? The precision of the sequence is changed The sequence is dropped The sequence is reverted to its minimum value d. The sequence is unchanged a. b. c.

7. Which statement will permanently remove all the data in, the indexes on, and

7. Which statement will permanently remove all the data in, the indexes on, and the structure of the PO_DETAIL table ? a. DROP TABLE po_detail; b. DELETE TABLE po_detail; c. ALTER TABLE po_detail d. TRUNCATE TABLE po_detail; e. SET UNUSED (po_num, po_line_id, product_id, quantity, unit_price);

8. Which statement type would be used to remove transactions more than one year

8. Which statement type would be used to remove transactions more than one year old from the TRX table ? a. DCL b. DDL c. DML d. DRL e. TCL

9. Which statements would cause an implicit COMMIT to occur ? a. GRANT b.

9. Which statements would cause an implicit COMMIT to occur ? a. GRANT b. SELECT c. COMMIT d. UPDATE e. ROLLBACK

10. Which CREATE TABLE statement will true ? a. CREATE TABLE date (time_id NUMBER(9));

10. Which CREATE TABLE statement will true ? a. CREATE TABLE date (time_id NUMBER(9)); b. CREATE TABLE time (time_id NUMBER(9)); c. CREATE TABLE $time (time_id NUMBER(9)); d. CREATE TABLE datetime (time_id NUMBER(9)); e. CREATE TABLE number (time_id NUMBER(9));

11. Evaluate this statement: TRUNCATE TABLE inventory; Which three users could succesfully issue this

11. Evaluate this statement: TRUNCATE TABLE inventory; Which three users could succesfully issue this statement> (choose three) a. The owner of the INVENTORY table b. Any user with access to the PUBLIC schema c. Any member of the CONNECT and RESOURCE roles d. Any user with the DROP ANY TABLE system privilege e. Any user with the DELETE object privilege on the INVENTORY table

12. Which Database Objects not incluided in a Oracle Database a. Table b. Sequence

12. Which Database Objects not incluided in a Oracle Database a. Table b. Sequence c. Constraint d. Synonym e. Index

13. Evaluate this SQL statement : SELECT c. customer_id, o. order_date, p. product_name FROM

13. Evaluate this SQL statement : SELECT c. customer_id, o. order_date, p. product_name FROM customers c, curr_order o, product p WHERE customer_id = curr_order. customer_id AND o. product_id = p. product_id ORDER BY o. order_amount; This statement fails when executed. Which changne will corect the problem? a. b. c. d. e. Use the table name in the ORDER BY clause Remove the table aliases from the WHERE clause Include the ORDER_AMOUNT column in the SELECT list. Use the table aliases instead of the table names in the WHERE clause Remove the table alias from the ORDER BY clauses and use only the column name

14. The WORKORDER table contains these columns : WO_ID NUMBER PK CUST_ID NUMBER REQUIRED_DT

14. The WORKORDER table contains these columns : WO_ID NUMBER PK CUST_ID NUMBER REQUIRED_DT DATE COMPL_DT DATE AMOUNT NUMBER (7, 2) Which statement regarding the use of aggregate functions on the WORKORDER table is true ? a. b. c. d. e. f. Using the AVG aggregate function with any column in the table is allowed Using the AVG aggregate function on the AMOUNT column ignores null values. Using the MIN aggregate function on the COMPL_DT column will return a null values. Using the SUM aggregate function with AMOUNT column is allowed in any portion of a SELECT statement. Using the SUM aggregate function on the AMOUNT column will result in erroneous result because the column contains null Grouping on the REQUIRED_DT and COMPL_DT column is NOT allowed.

15. Which two operators can be used in an outer join condition? a. b.

15. Which two operators can be used in an outer join condition? a. b. c. d. ALL OR IN AND

16. You want to produce a report containing the total number of orders placed

16. You want to produce a report containing the total number of orders placed for a particular time periode. Which aggregate functions should you use in your SQL statement? a. b. c. d. e. STOT TSUM VALUE COUNT STDDEV

17. The EVENT table contains these columns: EVENT_ID NUMBER EVENT_NAME VARCHAR 2(30) EVENT_DESC VARCHAR

17. The EVENT table contains these columns: EVENT_ID NUMBER EVENT_NAME VARCHAR 2(30) EVENT_DESC VARCHAR 2(100) EVENT_TYPE NUMBER LOCATION_ID NUMBER You have been asked to provide a report of the number of different event types at each location. Which SELECT statement will produce the desired result? a. b. c. d. e. SELECT UNIQUE(location_id), COUNT(event_type) FROM event GROUP BY location_id; SELECT COUNT(*), DISTINCT(location_id) FROM event; SELECT DISTINCT(event_type) FROM event GROUP BY location_id; SELECT location_id, COUNT(DISTINCT event_type) FROM event GROUP BY location_id; SELECT location_id, MAX(DISTINCT event_type) FROM event GROUP BY location_id;

18. How many levels can subqueries be nested in a FROM caluse? a. 2

18. How many levels can subqueries be nested in a FROM caluse? a. 2 b. 4 c. 8 d. 16 e. unlimited

19. Evaluate this SQL statement SELECT supplier_id, AVG(cost) FROM product WHERE AVG(list_price) > 60.

19. Evaluate this SQL statement SELECT supplier_id, AVG(cost) FROM product WHERE AVG(list_price) > 60. 00 GROUP BY supplier_id ORDER BY AVG(cost) DESC; Which clause will cause an error? a. SELECT b. WHERE c. GROUP BY d. ORDER BY

20. Which SELECT statement implements a self join? a. SELECT i. id_number, m. manufacturer_id

20. Which SELECT statement implements a self join? a. SELECT i. id_number, m. manufacturer_id FROM inventory i NATURAL JOIN inventory m; b. SELECT i. id_number, m. manufacturer_id FROM inventory i, inventory m WHERE i. manufacturer_id = m. id_number; c. SELECT i. id_number, m. manufacturer_id FROM inventory i, manufacturer m WHERE i. manufacturer_id = m. id_number; d. SELECT i. id_number, m. manufacturer_id FROM inventory i, manufacturer m WHERE i. manufacturer_id <> m. id_number;

21. How many values could a subquery used with the <> operator return? a.

21. How many values could a subquery used with the <> operator return? a. Only 1 b. Up to 2 c. Up to 10 d. unlimited

21. Evaluate this SELECT statement: SELECT employee_id, name FROM employee WHERE employee_id NOT IN

21. Evaluate this SELECT statement: SELECT employee_id, name FROM employee WHERE employee_id NOT IN (SELECT employee_id FROM employee WHERE department_id = 30 AND job = ‘CLERK’); What would happen if the inner query returned a NULL values? a. A syntax error would be returned b. No rows would beselected from the employee tables c. All the EMPLOYEE_ID and NAME values in the EMPLOYEE table would be displayed d. Only the rows with EMPLOYEE_ID values equal to NULL would be included in the results

22. You query the database with the SELECT statement: SELECT COUNT(instructor_id) FROM class; Which

22. You query the database with the SELECT statement: SELECT COUNT(instructor_id) FROM class; Which value is displayed? a. 2 b. 3 c. 4 d. 5 e. The statement will NOT execute succesfully CLASS_ID CLASS_NAME HOURS_CREDIT INSTRUCTOR_ID 1 Intro. To Acc. 3 4 2 Computer Basic 3 1 3 Tax Accounting 3 4 4 American History 3 2 5 Basic Engineering 3

23. The ID column in the CUSTOMER table that corresponds to the CUSTOMER_ID column

23. The ID column in the CUSTOMER table that corresponds to the CUSTOMER_ID column of the CURR_ORDER table contains null values for rows that need to be diaplayed. Which type of join should you use to display the data? a. equijoin b. self join c. outer join d. natural join

24. The TEACHER table in your schema contains these columns : ID NUMBER(9) NOT

24. The TEACHER table in your schema contains these columns : ID NUMBER(9) NOT NULL PERIMARY KEY LAST_NAME VARCHAR 2(25) FIRST_NAME VARCHAR 2(25) SUBJECT_ID NUMBER(9) You execute this statement: CREATE INDEX teacher_name_idx ON teacher(first_name, last_name); Which statements is true ? a. b. c. d. The statement creates a composite unique index. The statement will fail because It contains a syntax error. You must have the CREATE ANY INDEX privilege for the statemen to succed. The statement creates a composite non-unique index.

25. The ACCOUNT table contains these colums: ACCOUNT_ID NUMBER(12) NEW_BALANCE NUMBER(7, 2) PREV_BALANCE NUMBER(7,

25. The ACCOUNT table contains these colums: ACCOUNT_ID NUMBER(12) NEW_BALANCE NUMBER(7, 2) PREV_BALANCE NUMBER(7, 2) PAYMENTS NUMBER(7, 2) FINANCE_CHARGE NUMBER(7, 2) CREDIT_LIMIT NUMBER(7) You execute this statement: SELECT ROWNUM “Rank”, account_id, finance_charge FROM (SELECT account_id, finance_charge FROM account ORDER BY finance_charge ) WHERE ROWNUM <= 50; What statement regarding the execution of this statement is true? a. b. c. d. e. The statement failed to execute because an inline view was NOT used. The ORDER BY clause was ignored because it was NOT placed in the outer query. The 50 greatest finance charge values were displayed from the highest to the lowest. The statement failed to execute because the ORDER BY does NOT use the Top-n column. The 50 greatest finance charge values were displayed from the lowest to the highest.