OCA - SQL

116 Questions | Attempts: 139
Share

SettingsSettingsSettings
SQL Quizzes & Trivia

.


Questions and Answers
  • 1. 

    You execute the following commands: SQL > DEFINE hiredate = '01-APR-2011' SQL >SELECT employee_id, first_name, salary FROM employees WHERE hire_date > '&hiredate' AND manager_id > &mgr_id; For which substitution variables are you prompted for the input?

    • A.

      None, because no input required

    • B.

      Both the substitution variables ''hiredate' and 'mgr_id'.

    • C.

      Only hiredate'

    • D.

      Only 'mgr_id'

    Correct Answer
    D. Only 'mgr_id'
  • 2. 

    View the Exhibit and examine the structure of ORDERS and ORDER_ITEMS tables. ORDER_ID is the primary key in the ORDERS table. It is also the foreign key in the ORDER_ITEMS table wherein it is created with the ON DELETE CASCADE option. Which DELETE statement would execute successfully?

    • A.

      DELETE orders o, order_items I WHERE o.order_id = i.order_id;

    • B.

      DELETE FROM orders WHERE (SELECT order_id FROM order_items);

    • C.

      DELETE orders WHERE order_total < 1000;

    • D.

      DELETE order_id FROM orders WHERE order_total < 1000;

    Correct Answer
    B. DELETE FROM orders WHERE (SELECT order_id FROM order_items);
  • 3. 

    View the Exhibit and examine the structure of CUSTOMERS table. Using the CUSTOMERS table, you need to generate a report that shows an increase in the credit limit by 15% for all customers. Customers whose credit limit has not been entered should have the message "Not Available" displayed. Which SQL statement would produce the required result?

    • A.

      SELECT NVL (TO CHAR(cust_credit_limit * .15), 'Not Available') "NEW CREDIT" FROM customers;

    • B.

      SELECT TO_CHAR (NVL(cust_credit_limit * .15), 'Not Available') "NEW CREDIT" FROM customers;

    • C.

      SELECT NVL(cust_credit_limit * .15), 'Not Available') "NEW CREDIT" FROM customers;

    • D.

      SELECT NVL(cust_credit_limit), 'Not Available') "NEW CREDIT" FROM customers;

    Correct Answer
    A. SELECT NVL (TO CHAR(cust_credit_limit * .15), 'Not Available') "NEW CREDIT" FROM customers;
  • 4. 

    View the exhibit and examine the structures of the EMPLOYEES and DEPARTMENTS tables. EMPLOYEES Name Null? Type ----------------- ----- ------------- EMPLOYEE_ID NOT NULL NUMBER(6) FIRST_NAME VARCHAR2(20) LAST_NAME NOT NULL VARCHAR2(25) HIRE_DATE NOT NULL DATE JOB_ID NOT NULL VARCHAR2(10) SALARY NUMBER(10,2) COMMISSION NUMBER(6,2) MANAGER_ID NUMBER(6) DEPARTMENT_ID NUMBER(4) DEPARTMENTS Name Null? Type ----------------- ----- ------------- DEPARTMENT_ID NOT NULL NUMBER(4) DEPARTMENT_NAME NOT NULL VARCHAR2(30) MANAGER_ID NUMBER(6) LOCATION_ID NUMBER(4) You want to update EMPLOYEES table as follows: Update only those employees who work in Boston or Seattle (locations 2900 and 2700). Set department_id for these employees to the department_id corresponding to London (location_id 2100). Set the employees' salary in location_id 2100 to 1.1 times the average salary of their department. Set the employees' commission in location_id 2100 to 1.5 times the average commission of their department. You issue the following command: SQL> UPDATE employees SET department_id = (SELECT department_id FROM departments WHERE location_id = 2100), (salary, commission) = (SELECT 1.1*AVG(salary), 1.5*AVG(commission) FROM employees, departments WHERE departments.location_id IN(2900, 2700, 2100)) WHERE department_id IN (SELECT department_id FROM departments WHERE location_id = 2900 OR location_id = 2700; What is outcome?

    • A.

      It generates an error because multiple columns (SALARY, COMMISSION) cannot be specified together in an UPDATE statement.

    • B.

      It generates an error because a subquery cannot have a join condition in a UPDATE statement.

    • C.

      It executes successfully and gives the desired update

    • D.

      It executes successfully but does not give the desired update

    Correct Answer
    D. It executes successfully but does not give the desired update
  • 5. 

    Evaluate the following two queries: SQL> SELECT cust_last_name, cust_city FROM customers WHERE cust_credit_limit IN (1000, 2000, 3000); SQL> SELECT cust_last_name, cust_city FROM customers WHERE cust_credit_limit = 1000 or cust_credit_limit = 2000 or cust_credit_limit = 3000 Which statement is true regarding the above two queries?

    • A.

      Performance would improve in query 2 only if there are null values in the CUST_CREDIT_LIMIT column.

    • B.

      There would be no change in performance.

    • C.

      Performance would degrade in query 2.

    • D.

      Performance would improve in query 2.

    Correct Answer
    B. There would be no change in performance.
  • 6. 

    Examine the business rule: Each student can work on multiple projects and each project can have multiple students. You need to design an Entity Relationship Model (ERD) for optimal data storage and allow for generating reports in this format: STUDENT_ID FIRST_NAME LAST_NAME PROJECT_ID PROJECT_NAME PROJECT_TASK Which two statements are true in this scenario?

    • A.

      The ERD must have a 1:M relationship between the STUDENTS and PROJECTS entities.

    • B.

      The ERD must have a M:M relationship between the STUDENTS and PROJECTS entities that must be resolved into 1:M relationships.

    • C.

      STUDENT_ID must be the primary key in the STUDENTS entity and foreign key in the PROJECTS entity.

    • D.

      PROJECT_ID must be the primary key in the PROJECTS entity and foreign key in the STUDENTS entity.

    • E.

      An associative table must be created with a composite key of STUDENT_ID and PROJECT_ID, which is the foreign key linked to the STUDENTS and PROJECTS entities.

    Correct Answer(s)
    B. The ERD must have a M:M relationship between the STUDENTS and PROJECTS entities that must be resolved into 1:M relationships.
    E. An associative table must be created with a composite key of STUDENT_ID and PROJECT_ID, which is the foreign key linked to the STUDENTS and PROJECTS entities.
  • 7. 

    View the Exhibit and examine the details of PRODUCT_INFORMATION table. You have the requirement to display PRODUCT_NAME from the table where the CATEGORY_ID column has values 12 or 13, and the SUPPLIER_ID column has the value 102088. You executed the following SQL statement: SELECT product_name FROM product_information WHERE (category_id = 12 AND category_id = 13) AND supplier_id = 102088; Which statement is true regarding the execution of the query?

    • A.

      It would not execute because the same column has been used in both sides of the AND logical operator to form the condition.

    • B.

      It would not execute because the entire WHERE clause condition is not enclosed within the parentheses.

    • C.

      It would execute and the output would display the desired result.

    • D.

      It would execute but the output would return no rows.

    Correct Answer
    D. It would execute but the output would return no rows.
  • 8. 

    Which two statements are true regarding the EXISTS operator used in the correlated subqueries? (Choose two.)

    • A.

      The outer query stops evaluating the result set of the inner query when the first value is found.

    • B.

      It is used to test whether the values retrieved by the inner query exist in the result of the outer query.

    • C.

      It is used to test whether the values retrieved by the outer query exist in the result set of the inner query.

    • D.

      The outer query continues evaluating the result set of the inner query until all the values in the result set are processed.

    Correct Answer(s)
    A. The outer query stops evaluating the result set of the inner query when the first value is found.
    C. It is used to test whether the values retrieved by the outer query exist in the result set of the inner query.
  • 9. 

    View the exhibit and examine the structure of the STORES table. STORES table Name Null? Type ----------------- ----- ------------- STORE_ID NUMBER NAME VARCHAR2(100) ADDRESS VARCHAR2(200) CITY VARCHAR2(100) COUNTRY VARCHAR2(100) START_DATE DATE END_DATE DATE PROPERTY_PRICE NUMBER You want to display the NAME of the store along with the ADDRESS, START_DATE, PROPERTY_PRICE, and the projected property price, which is 115% of property price. The stores displayed must have START_DATE in the range of 36 months starting from 01-Jan-2000 and above. Which SQL statement would get the desired output?

    • A.

      SELECT name, concat (address| | ','| |city| |', ', country) AS full_address, start_date, property_price, property_price*115/100 FROM stores WHERE MONTHS_BETWEEN (start_date, '01-JAN-2000')

    • B.

      SELECT name, concat (address| | ','| |city| |', ', country) AS full_address, start_date, property_price, property_price*115/100 FROM stores WHERE TO_NUMBER(start_date-TO_DATE('01-JAN-2000','DD-MON-RRRR'))

    • C.

      SELECT name, address||','||city||','||country AS full_address, start_date, property_price, property_price*115/100 FROM stores WHERE MONTHS_BETWEEN (start_date, TO_DATE('01-JAN-2000','DD-MON-RRRR'))

    • D.

      SELECT name, concat (address||','| |city| |', ', country) AS full_address, start_date, property_price, property_price*115/100 FROM stores WHERE MONTHS_BETWEEN (start_date, TO_DATE('01-JAN-2000','DD-MON-RRRR'))

    Correct Answer
    D. SELECT name, concat (address||','| |city| |', ', country) AS full_address, start_date, property_price, property_price*115/100 FROM stores WHERE MONTHS_BETWEEN (start_date, TO_DATE('01-JAN-2000','DD-MON-RRRR'))
  • 10. 

    The BOOKS_TRANSACTIONS table exists in your database. SQL>SELECT * FROM books_transactions ORDER BY 3; What is the outcome on execution?

    • A.

      The execution fails unless the numeral 3 in the ORDER BY clause is replaced by a column name.

    • B.

      Rows are displayed in the order that they are stored in the table only for the three rows with the lowest values in the key column.

    • C.

      Rows are displayed in the order that they are stored in the table only for the first three rows.

    • D.

      Rows are displayed sorted in ascending order of the values in the third column in the table.

    Correct Answer
    D. Rows are displayed sorted in ascending order of the values in the third column in the table.
  • 11. 

    Examine the command: SQL> ALTER TABLE books_transactions ADD CONSTRAINT fk_book_id FOREIGN KEY (book_id) REFERENCES books (book_id) ON DELETE CASCADE; What does ON DELETE CASCADE imply?

    • A.

      When the BOOKS table is dropped, the BOOK_TRANSACTIONS table is dropped.

    • B.

      When the BOOKS table is dropped, all the rows in the BOOK_TRANSACTIONS table are deleted but the table structure is retained.

    • C.

      When a row in the BOOKS table is deleted, the rows in the BOOK_TRANSACTIONS table whose BOOK_ID matches that of the deleted row in the BOOKS table are also deleted.

    • D.

      When a value in the BOOKS.BOOK_ID column is deleted, the corresponding value is updated in the BOOKS_TRANSACTIONS.BOOK_ID column.

    Correct Answer
    C. When a row in the BOOKS table is deleted, the rows in the BOOK_TRANSACTIONS table whose BOOK_ID matches that of the deleted row in the BOOKS table are also deleted.
  • 12. 

    View the exhibit and examine the structure of the EMPLOYEES table. You want to display all employees and their managers having 100 as the MANAGER_ID. You want the output in two columns: the first column would have the LAST_NAME of the managers and the second column would have LAST_NAME of the employees. Which SQL statement would you execute?

    • A.

      SELECT m.last_name "Manager", e.last_name "Employee" FROM employees m JOIN employees e ON m.employee_id = e.manager_id WHERE m.manager_id = 100;

    • B.

      SELECT m.last_name "Manager", e.last_name "Employee" FROM employees m JOIN employees e ON m.employee_id = e.manager_id WHERE e.manager_id = 100;

    • C.

      SELECT m.last_name "Manager", e.last_name "Employee" FROM employees m JOIN employees e ON e.employee_id = m.manager_id WHERE m.manager_id = 100;

    • D.

      SELECT m.last_name "Manager", e.last_name "Employee" FROM employees m JOIN employees e WHERE m.employee_id = e.manager_id and AND e.manager_id = 100

    Correct Answer
    B. SELECT m.last_name "Manager", e.last_name "Employee" FROM employees m JOIN employees e ON m.employee_id = e.manager_id WHERE e.manager_id = 100;
  • 13. 

    Which three statements are true about multiple-row subqueries?

    • A.

      They can contain a subquery within a subquery.

    • B.

      They can return multiple columns as well as rows.

    • C.

      They cannot contain a subquery within a subquery.

    • D.

      They can return only one column but multiple rows.

    • E.

      They can contain group functions and GROUP BY and HAVING clauses.

    • F.

      They can contain group functions and the GROUP BY clause, but not the HAVING clause.

    Correct Answer(s)
    A. They can contain a subquery within a subquery.
    B. They can return multiple columns as well as rows.
    E. They can contain group functions and GROUP BY and HAVING clauses.
  • 14. 

    Examine the structure of the EMPLOYEES table. Name Null? Type ----------------- ----- ------ ------ EMPLOYEE_ID NOT NULL NUMBER(6) FIRST_NAME VARCHAR2(20) LAST_NAME NOT NULL VARCHAR2(25) EMAIL NOT NULL VARCHAR2(25) PHONE NUMBER VARCHAR2(20) HIRE_DATE NOT NULL DATE JOB_ID NOT NULL VARCHAR2(10) SALARY NUMBER(8,2) COMMISSION_PCT NUMBER(2,2) MANAGER_ID NUMBER(6) DEPARTMENT_ID NUMBER(4) There is a parent/child relationship between EMPLOYEE_ID and MANAGER_ID. You want to display the last names and manager IDs of employees who work for the same manager as the employee whose EMPLOYEE_ID is 123. Which query provides the correct output?

    • A.

      SELECT e.last_name, m.manager_id FROM employees e RIGHT OUTER JOIN employees m on (e.manager_id = m.employee_id) AND e.employee_id = 123;

    • B.

      SELECT e.last_name, m.manager_id FROM employees e RIGHT OUTER JOIN employees m on (e.employee_id = m.manager_id) WHERE e.employee_id = 123;

    • C.

      SELECT e.last_name, e.manager_id FROM employees e RIGHT OUTER JOIN employees m on (e.employee_id = m.employee_id) WHERE e.employee_id = 123;

    • D.

      SELECT m.last_name, e.manager_id FROM employees e LEFT OUTER JOIN employees m on (e.manager_id = m.manager_id) WHERE e.employee_id = 123;

    Correct Answer
    B. SELECT e.last_name, m.manager_id FROM employees e RIGHT OUTER JOIN employees m on (e.employee_id = m.manager_id) WHERE e.employee_id = 123;
  • 15. 

    Which normal form is a table in if it has no multi-valued attributes and no partial dependencies?

    • A.

      Second normal form

    • B.

      First normal form

    • C.

      Third normal form

    • D.

      Fourth normal form

    Correct Answer
    A. Second normal form
  • 16. 

    Sales data of a company is stored in two tables, SALES1 and SALES2, with some data being duplicated across the tables. You want to display the results from the SALES1 table, which are not present in the SALES2 table. SALES1 table Name           Null            Type ------------------ ------------- ---------------- SALES_ID NUMBER STORE_ID NUMBER ITEMS_ID NUMBER QUANTITY NUMBER SALES_DATE DATE SALES2 table Name             Null        Type ---------------- ------------- ----------------- SALES_ID NUMBER STORE_ID NUMBER ITEMS_ID NUMBER QUANTITY NUMBER SALES_DATE DATE Which set operator generates the required output?

    • A.

      INTERSECT

    • B.

      UNION

    • C.

      PLUS

    • D.

      MINUS

    • E.

      SUBTRACT

    Correct Answer
    D. MINUS
  • 17. 

    Evaluate the following ALTER TABLE statement: ALTER TABLE orders SET UNUSED (order_date); Which statement is true?

    • A.

      After executing the ALTER TABLE command, you can add a new column called ORDER_DATE to the ORDERS table.

    • B.

      The ORDER_DATE column should be empty for the ALTER TABLE command to execute succsessfully.

    • C.

      ROLLBACK can be used to get back the ORDER_DATE column in the ORDERS table.

    • D.

      The DESCRIBE command would still display the ORDER_DATE column.

    Correct Answer
    A. After executing the ALTER TABLE command, you can add a new column called ORDER_DATE to the ORDERS table.
  • 18. 

    Evaluate the following SQL statements that are issued in the given order: CREATE TABLE emp (emp_no NUMBER(2) CONSTRAINT emp_emp_no_pk PRIMARY KEY, ename VARCHAR2(15), salary NUMBER (8,2), mgr_no NUMBER(2) CONSTRAINT emp_mgr_fk REFERENCES emp(emp_no)); ALTER TABLE emp DISABLE CONSTRAINT emp_emp_no_pk CASCADE; ALTER TABLE emp ENABLE CONSTRAINT emp_emp_no_pk; What would be the status of the foreign key EMP_MGR_PK?

    • A.

      It would remain disabled and can be enabled only by dropping the foreign key constraint and recreating it.

    • B.

      It would remain disabled and has to be enabled manually using the ALTER TABLE command.

    • C.

      It would be automatically enabled and immediate.

    • D.

      It would be automatically enabled and deferred.

    Correct Answer
    B. It would remain disabled and has to be enabled manually using the ALTER TABLE command.
  • 19. 

    Which three statements are true regarding the data types?

    • A.

      The minimum column width that can be specified for a VARCHAR2 data type column is one.

    • B.

      Only one LONG column can be used per table.

    • C.

      A TIMESTAMP data type column stores only time values with fractional seconds.

    • D.

      The BLOB data type column is used to store binary data in an operating system file.

    • E.

      The value for a CHAR data type column is blank-padded to the maximum defined column width.

    Correct Answer(s)
    A. The minimum column width that can be specified for a VARCHAR2 data type column is one.
    B. Only one LONG column can be used per table.
    E. The value for a CHAR data type column is blank-padded to the maximum defined column width.
  • 20. 

    Which three statements are true regarding subqueries?

    • A.

      Multiple columns or expressions can be compared between the main query and subquery.

    • B.

      Subqueries can contain ORDER BY but not the GROUP BY clause.

    • C.

      Main query and subquery can get data from different tables.

    • D.

      Subqueries can contain GROUP BY and ORDER BY clauses.

    • E.

      Main query and subquery must get data from the same tables.

    • F.

      Only one column or expression can be compared between the main query and subquery.

    Correct Answer(s)
    A. Multiple columns or expressions can be compared between the main query and subquery.
    C. Main query and subquery can get data from different tables.
    D. Subqueries can contain GROUP BY and ORDER BY clauses.
  • 21. 

    Which statement is true regarding the default behavior of the ORDER BY clause?

    • A.

      In a character sort, the values are case-sensitive.

    • B.

      NULL values are not considered at all by the sort operation.

    • C.

      Only those columns that are specified in the SELECT list can be used in the ORDER BY clause.

    • D.

      Numeric values are displayed from the maximum to the minimum value if they have decimal positions.

    Correct Answer
    A. In a character sort, the values are case-sensitive.
  • 22. 

    Which task can be performed by using a single Data Manipulation Language (DML) statement?

    • A.

      Adding a column constraint when inserting a row into a table

    • B.

      Adding a column with a default value when inserting a row into a table

    • C.

      Removing all data only from one single column on which a unique constraint is defined

    • D.

      Removing all data only from one single column on which a primary key constraint is defined

    Correct Answer
    C. Removing all data only from one single column on which a unique constraint is defined
  • 23. 

    Examine the structure of the BOOKS_TRANSACTIONS table: Name                                       Null?                          Type ----------------                                 -----------------                    --------------------------- TRANSACTION_ID                   NOT NULL                      VARCHAR2 (6) BORROWED_DATE                                                           VARCHAR2 (50) DUE_DATE                                                                         DATE BOOK_ID                                                                             DATE MEMBER_ID                                                                       VARCHAR2 (6) You want to display the member IDs, due date, and late fee as $2 for all transactions. Which SQL statement must you execute?

    • A.

      SELECT member_id AS MEMBER_ID, due_date AS DUE_DATE, $2 AS LATE_FEE FROM BOOKS_TRANSACTIONS;

    • B.

      SELECT member_id 'MEMBER ID', due_date 'DUE DATE', '$2 AS LATE FEE' FROM BOOKS_TRANSACTIONS;

    • C.

      SELECT member_id AS "MEMBER ID", due_date AS "DUE DATE", '$2' AS "LATE FEE" FROM BOOKS_TRANSACTIONS;

    • D.

      SELECT member_id AS "MEMBER ID", due_date AS "DUE DATE", $2 AS "LATE FEE" FROM BOOKS_TRANSACTIONS;

    Correct Answer
    C. SELECT member_id AS "MEMBER ID", due_date AS "DUE DATE", '$2' AS "LATE FEE" FROM BOOKS_TRANSACTIONS;
  • 24. 

    In which three situations does a transaction complete?

    • A.

      When a PL/SQL anonymous block is executed

    • B.

      When a DELETE statement is executed

    • C.

      When a ROLLBACK command is executed

    • D.

      When a data definition language (DDL) statement is executed

    • E.

      When a TRUNCATE statement is executed after the pending transaction

    Correct Answer(s)
    C. When a ROLLBACK command is executed
    D. When a data definition language (DDL) statement is executed
    E. When a TRUNCATE statement is executed after the pending transaction
  • 25. 

    View the exhibit and examine the data in ORDERS_MASTER and MONTHLY_ORDERS tables. Evaluate the following MERGE statement: MERGE_INTO orders_master o USING monthly_orders m ON (o.order_id = m.order_id) WHEN MATCHED THEN UPDATE SET o.order_total = m.order_total DELETE WHERE (m.order_total IS NULL) WHEN NOT MATCHED THEN INSERT VALUES (m.order_id, m.order_total) What would be the outcome of the above statement?

    • A.

      The ORDERS_MASTER table would contain the ORDER_IDs 1, 2, 3 and 4.

    • B.

      The ORDERS_MASTER table would contain the ORDER_IDs 1, 2 and 4.

    • C.

      The ORDERS_MASTER table would contain the ORDER_IDs 1, 2 and 3.

    • D.

      The ORDERS_MASTER table would contain the ORDER_IDs 1 and 2.

    Correct Answer
    B. The ORDERS_MASTER table would contain the ORDER_IDs 1, 2 and 4.
  • 26. 

    Evaluate the following SQL statement: SELECT product_name || 'it's not available for order' FROM product_information WHERE product_status = 'obsolete'; You received the following error while executing the above query: ERROR ORA-01756: quoted string not properly terminated What would you do to execute the query successfully?

    • A.

      Use Quote (q) operator and delimiter to allow the use of single quotation mark in the literal character string.

    • B.

      Enclose the literal character string in the SELECT clause within the double quotation marks.

    • C.

      Do not enclose the character literal string in the SELECT clause within the single quotation marks.

    • D.

      Use escape character to negate the single quotation mark inside the literal character string in the SELECT clause.

    Correct Answer
    A. Use Quote (q) operator and delimiter to allow the use of single quotation mark in the literal character string.
  • 27. 

    View the exhibit and examine the ORDERS table. ORDERS Name                                       Null?                                                    Type ORDER ID                                 NOT NULL                                        NUMBER(4) ORDATE DATE                                                                                    DATE CUSTOMER ID                                                                                    NUMBER(3) ORDER TOTAL                                                                                     NUMBER(7,2) The ORDERS table contains data and all orders have been assigned a customer ID. Which statement would add a NOT NULL constraint to the CUSTOMER_ID column?

    • A.

      ALTER TABLE orders MODIFY CONSTRAINT orders_cust_id_nn NOT NULL (customer_id);

    • B.

      ALTER TABLE orders ADD CONSTRAINT orders_cust_id_nn NOT NULL (customer_id);

    • C.

      ALTER TABLE orders MODIFY customer_id CONSTRAINT orders_cust_nn NOT NULL (customer_id);

    • D.

      ALTER TABLE orders ADD customer_id NUMBER(6)CONSTRAINT orders_cust_id_nn NOT NULL;

    Correct Answer
    C. ALTER TABLE orders MODIFY customer_id CONSTRAINT orders_cust_nn NOT NULL (customer_id);
  • 28. 

    Examine the structure of the INVOICE table. Name                                                Null?                                                 Type ------------------                                      -------------------                                    ------------- INV_NO                                             NOT NULL                                         NUMBER(3) INV_DATE                                                                                                     DATE INV_AMT                                                                                                      NUMBER(10,2) Which two SQL statements would execute successfully?

    • A.

      SELECT inv_no, NVL2(inv_date, 'Pending', 'Incomplete') FROM invoice;

    • B.

      SELECT inv_no, NVL2(inv_amt, inv_date, 'Not Available') FROM invoice;

    • C.

      SELECT inv_no, NVL2(inv_date, sysdate-inv_date, sysdate) FROM invoice;

    • D.

      SELECT inv_no, NVL2(inv_amt, inv_amt*.25, 'Not Available') FROM invoice;

    Correct Answer(s)
    A. SELECT inv_no, NVL2(inv_date, 'Pending', 'Incomplete') FROM invoice;
    C. SELECT inv_no, NVL2(inv_date, sysdate-inv_date, sysdate) FROM invoice;
  • 29. 

    Which three statements are true about the ALTER TABLE....DROP COLUMN.... command?

    • A.

      A column can be dropped only if it does not contain any data.

    • B.

      A column can be dropped only if another column exists in the table.

    • C.

      A dropped column can be rolled back.

    • D.

      The column in a composite PRIMARY KEY with the CASCADE option can be dropped.

    • E.

      A parent key column in the table cannot be dropped.

    Correct Answer(s)
    B. A column can be dropped only if another column exists in the table.
    D. The column in a composite PRIMARY KEY with the CASCADE option can be dropped.
    E. A parent key column in the table cannot be dropped.
  • 30. 

    View the exhibit and examine the description of the PRODUCT_INFORMATION table. Which SQL statement would retrieve from the table the number of products having LIST_PRICE as NULL?

    • A.

      SELECT COUNT (DISTINCT list_price) FROM product_information WHERE list_price is NULL

    • B.

      SELECT COUNT (NVL(list_price, 0)) FROM product_information WHERE list_price is NULL

    • C.

      SELECT COUNT (list_price) FROM product_information WHERE list_price i= NULL

    • D.

      SELECT COUNT (list_price) FROM product_information WHERE list_price is NULL

    Correct Answer
    B. SELECT COUNT (NVL(list_price, 0)) FROM product_information WHERE list_price is NULL
  • 31. 

    Which three tasks can be performed using SQL functions built into Oracle Database?

    • A.

      Displaying a date in a nondefault format

    • B.

      Finding the number of characters in an expression

    • C.

      Substituting a character string in a text expression with a specified string

    • D.

      Combining more than two columns or expressions into a single column in the output

    Correct Answer(s)
    A. Displaying a date in a nondefault format
    B. Finding the number of characters in an expression
    C. Substituting a character string in a text expression with a specified string
  • 32. 

    The user SCOTT who is the owner of ORDERS and ORDER_ITEMS tables issues the following GRANT command: GRANT ALL ON orders, order_items TO PUBLIC; What correction needs to be done to the above statement?

    • A.

      PUBLIC should be replaced with specific usernames.

    • B.

      ALL should be replaced with a list of specific privileges.

    • C.

      WITH GRANT OPTION should be added to the statement.

    • D.

      Separate GRANT statements are required for ORDERS and ORDER_ITEMS tables.

    Correct Answer
    D. Separate GRANT statements are required for ORDERS and ORDER_ITEMS tables.
  • 33. 

    You are designing the structure of a table in which two columns have the specifications: COMPONENT_ID – must be able to contain a maximum of 12 alphanumeric characters and uniquely identify the row EXECUTION_DATETIME – contains Century, Year, Month, Day, Hour, Minute, Second to the maximum precision and is used for calculations and comparisons between components. Which two options define the data types that satisfy these requirements most efficiently?

    • A.

      The EXECUTION_DATETIME must be of INTERVAL DAY TO SECOND data type.

    • B.

      The EXECUTION_DATETIME must be of TIMESTAMP data type.

    • C.

      The EXECUTION_DATETIME must be of DATE data type.

    • D.

      The COMPONENT_ID must be of ROWID data type.

    • E.

      The COMPONENT_ID must be of VARCHAR2 data type.

    • F.

      The COMPONENT_ID column must be of CHAR data type.

    Correct Answer(s)
    C. The EXECUTION_DATETIME must be of DATE data type.
    F. The COMPONENT_ID column must be of CHAR data type.
  • 34. 

    You want to display the date for the first Monday of the next month and issue the following command: SQL>SELECT TO_CHAR(NEXT_DAY(LAST_DAY(SYSDATE), 'MON'), 'dd "is the first Monday for" fmmonth rrrr') FROM DUAL; What is the outcome?

    • A.

      In generates an error because rrrr should be replaced by rr in the format string.

    • B.

      It executes successfully but does not return the correct result.

    • C.

      It executes successfully and returns the correct result.

    • D.

      In generates an error because TO_CHAR should be replaced with TO_DATE.

    • E.

      In generates an error because fm and double quotation marks should not be used in the format string.

    Correct Answer
    C. It executes successfully and returns the correct result.
  • 35. 

    Which two statements are true regarding the GROUP BY clause in a SQL statement? (Choose two.)

    • A.

      You can use column alias in the GROUP BY clause.

    • B.

      Using the WHERE clause after the GROUP BY clause excludes the rows after creating groups.

    • C.

      The GROUP BY clause is mandatory if you are using an aggregate function in the SELECT clause.

    • D.

      Using the WHERE clause before the GROUP BY clause excludes the rows before creating groups.

    • E.

      If the SELECT clause has an aggregate function, then those individual columns without an aggregate function in the SELECT clause should be included in the GROUP BY cause.

    Correct Answer(s)
    D. Using the WHERE clause before the GROUP BY clause excludes the rows before creating groups.
    E. If the SELECT clause has an aggregate function, then those individual columns without an aggregate function in the SELECT clause should be included in the GROUP BY cause.
  • 36. 

    Examine the commands used to create DEPARTMENT_DETAILS and COURSE_DETAILS: SQL>CREATE TABLE DEPARTMENT_DETAILS (DEPARTMENT_ID NUMBER PRIMARY KEY, DEPARTMENT_NAME VARCHAR2(50), HOD VARCHAR2(50)); SQL>CREATE TABLE COURSE_DETAILS (COURSE_ID NUMBER PRIMARY KEY, COURSE_NAME VARCHAR2(50), DEPARTMENT_ID VARCHAR2(50)); You want to generate a list of all department IDs along with any course IDs that may have been assigned to them. Which SQL statement must you use?

    • A.

      SELECT d.department_id, c.course_id FROM department_details d RIGHT OUTER JOIN course_details c ON (d.department_id=c. department_id);

    • B.

      SELECT d.department_id, c.course_id FROM department_details d LEFT OUTER JOIN course_details c ON (d.department_id=c. department_id);

    • C.

      SELECT d.department_id, c.course_id FROM course_details c LEFT OUTER JOIN department_details d ON (c.department_id=d. department_id);

    • D.

      SELECT d.department_id, c.course_id FROM department_details d RIGHT OUTER JOIN course_details c ON (c.department_id=d. department_id);

    Correct Answer
    B. SELECT d.department_id, c.course_id FROM department_details d LEFT OUTER JOIN course_details c ON (d.department_id=c. department_id);
  • 37. 

    View the exhibit and examine the description of the DEPARTMENTS and EMPLOYEES tables. The retrieve data for all the employees for their EMPLOYEE_ID, FIRST_NAME, and DEPARTMENT NAME, the following SQL statement was written: SELECT employee_id, first_name, department_name FROM employees NATURAL JOIN departments; The desired output is not obtained after executing the above SQL statement. What could be the reason for this?

    • A.

      The table prefix is missing for the column names in the SELECT clause.

    • B.

      The NATURAL JOIN clause is missing the USING clause.

    • C.

      The DEPARTMENTS table is not used before the EMPLOYEES table in the FROM clause.

    • D.

      The EMPLOYEES and DEPARTMENTS tables have more than one column with the same column name and data type.

    Correct Answer
    D. The EMPLOYEES and DEPARTMENTS tables have more than one column with the same column name and data type.
  • 38. 

    Which two statements are true about sequences created in a single instance database? (Choose two.)

    • A.

      When the MAXVALUE limit for the sequence is reached, you can increase the MAXVALUE limit by using the ALTER SEQUENCE statement.

    • B.

      DELETE would remove a sequence from the database.

    • C.

      The numbers generated by a sequence can be used only for one table.

    • D.

      CURRVAL is used to refer to the last sequence number that has been generated.

    • E.

      When a database instance shuts down abnormally, the sequence numbers that have been cached but not used would be available once again when the database instance is restarted.

    Correct Answer(s)
    A. When the MAXVALUE limit for the sequence is reached, you can increase the MAXVALUE limit by using the ALTER SEQUENCE statement.
    D. CURRVAL is used to refer to the last sequence number that has been generated.
  • 39. 

    View the exhibit and examine the structure of the CUSTOMERS table. Which two tasks would require subqueries or joins to be executed in a single statement?

    • A.

      Finding the number of customers, in each city, whose credit limit is more than the average credit limit of all the customers

    • B.

      Finding the average credit limit of male customers residing in 'Tokyo' or 'Sydney'

    • C.

      Listing of customers who do not have a credit limit and were born before 1980

    • D.

      Finding the number of customers, in each city, who‟s marital status is 'married'.

    • E.

      Listing of those customers, whose credit limit is the same as the credit limit of customers residing in the city 'Tokyo'.

    Correct Answer(s)
    A. Finding the number of customers, in each city, whose credit limit is more than the average credit limit of all the customers
    E. Listing of those customers, whose credit limit is the same as the credit limit of customers residing in the city 'Tokyo'.
  • 40. 

    Which statement is true about transactions?

    • A.

      A set of Data Manipulation Language (DML) statements executed in a sequence ending with a SAVEPOINT forms a single transaction.

    • B.

      Each Data Definition Language (DDL) statement executed forms a single transaction.

    • C.

      A set of DDL statements executed in a sequence ending with a COMMIT forms a single transaction.

    • D.

      A combination of DDL and DML statements executed in a sequence ending with a COMMIT forms a single transaction.

    Correct Answer
    B. Each Data Definition Language (DDL) statement executed forms a single transaction.
  • 41. 

    The first DROP operation is performed on PRODUCTS table using the following command: DROP TABLE products PURGE; Then you performed the FLASHBACK operation by using the following command: FLASHBACK TABLE products TO BEFORE DROP; Which statement describes the outcome of the FLASHBACK command?

    • A.

      It recovers only the table structure.

    • B.

      It recovers the table structure, data, and the indexes.

    • C.

      It recovers the table structure and data but not the related indexes.

    • D.

      It is not possible to recover the table structure, data, or the related indexes.

    Correct Answer
    D. It is not possible to recover the table structure, data, or the related indexes.
  • 42. 

    The following are the steps for a correlated subquery, listed in random order: 1. The WHERE clause of the outer query is evaluated. 2. The candidate row is fetched from the table specified in the outer query. 3. This is repeated for the subsequent rows of the table, till all the rows are processed. 4. Rows are returned by the inner query, after being evaluated with the value from the candidate row in the outer query. Which is the correct sequence in which the Oracle server evaluates a correlated subquery?

    • A.

      2, 1, 4, 3

    • B.

      4, 1, 2, 3

    • C.

      4, 2, 1, 3

    • D.

      2, 4, 1, 3

    Correct Answer
    D. 2, 4, 1, 3
  • 43. 

    Evaluate the following query: SQL> SELECT TRUNC (ROUND(156.00, -1),-1) FROM DUAL; What would be the outcome?

    • A.

      150

    • B.

      200

    • C.

      160

    • D.

      16

    • E.

      100

    Correct Answer
    C. 160
  • 44. 

    Examine the data in the CUST_NAME column of the CUSTOMERS table. CUST_NAME ------------------- Renske Ladwig Jason Mallin Samuel McCain Allan MCEwen Irene Mikilineni Julia Nayer You need to display customers' second names where the second name starts with "Mc" or "MC". Which query gives the required output?

    • A.

      SELECT SUBSTR (cust_name, INSTR (cust_name, ' ')+1) FROM customers WHERE SUBSTR (cust_name, INSTR (cust_name, ' ')+1) LIKE INITCAP ('MC%');

    • B.

      SELECT SUBSTR (cust_name, INSTR (cust_name, ' ')+1) FROM customers WHERE INITCAP (SUBSTR(cust_name, INSTR (cust_name, ' ')+1)) = 'Mc';

    • C.

      SELECT SUBSTR (cust_name, INSTR (cust_name, ' ')+1) FROM customers WHERE INITCAP (SUBSTR(cust_name, INSTR (cust_name, ' ')+1)) LIKE 'Mc%';

    • D.

      SELECT SUBSTR (cust_name, INSTR (cust_name, ' ')+1) FROM customers WHERE INITCAP (SUBSTR(cust_name, INSTR (cust_name, ' ')+1)) = INITCAP 'MC%';

    Correct Answer
    C. SELECT SUBSTR (cust_name, INSTR (cust_name, ' ')+1) FROM customers WHERE INITCAP (SUBSTR(cust_name, INSTR (cust_name, ' ')+1)) LIKE 'Mc%';
  • 45. 

    View the exhibit and examine the structure of the SALES, CUSTOMERS, PRODUCTS and TIMES tables. The PROD_ID column is the foreign key in the SALES tables, which references the PRODUCTS table. Similarly, the CUST_ID and TIME_ID columns are also foreign keys in the SALES table referencing the CUSTOMERS and TIMES tables, respectively. Evaluate the following CREATE TABLE command: CREATE TABLE new_sales (prod_id, cust_id, order_date DEFAULT SYSDATE) AS SELECT prod_id, cust_id, time_id FROM sales; Which statement is true regarding the above command?

    • A.

      The NEW_SALES table would get created and all the NOT NULL constraints defined on the specified columns would be passed to the new table.

    • B.

      The NEW_SALES table would not get created because the DEFAULT value cannot be specified in the column definition.

    • C.

      The NEW_SALES table would not get created because the column names in the CREATE TABLE command and the SELECT clause do not match.

    • D.

      The NEW_SALES table would get created and all the FOREIGN KEY constraints defined on the specified columns would be passed to the new table.

    Correct Answer
    A. The NEW_SALES table would get created and all the NOT NULL constraints defined on the specified columns would be passed to the new table.
  • 46. 

    Evaluate the following SELECT statement and view the exhibit to examine its output: SELECT constraint_name, constraint_type, search_condition, r_constraint_name, delete_rule, status, FROM user_constraints WHERE table_name = 'ORDERS'; Which two statements are true about the output? (Choose two.)

    • A.

      The R_CONSTRAINT_NAME column gives the alternative name for the constraint.

    • B.

      In the second column, 'c' indicates a check constraint.

    • C.

      The STATUS column indicates whether the table is currently in use.

    • D.

      The column DELETE_RULE decides the state of the related rows in the child table when the corresponding row is deleted from the parent table.

    Correct Answer(s)
    B. In the second column, 'c' indicates a check constraint.
    D. The column DELETE_RULE decides the state of the related rows in the child table when the corresponding row is deleted from the parent table.
  • 47. 

    Which three statements are true regarding group functions? (Choose three.)

    • A.

      They can be used on columns or expressions.

    • B.

      They can be passed as an argument to another group function.

    • C.

      They can be used only with a SQL statement that has the GROUP BY clause.

    • D.

      They can be used on only one column in the SELECT clause of a SQL statement.

    • E.

      They can be used along with the single-row function in the SELECT clause of a SQL statement.

    Correct Answer(s)
    A. They can be used on columns or expressions.
    B. They can be passed as an argument to another group function.
    E. They can be used along with the single-row function in the SELECT clause of a SQL statement.
  • 48. 

    Which statements are true? (Choose all that apply.)

    • A.

      The data dictionary is created and maintained by the database administrator.

    • B.

      The data dictionary views consists of joins of dictionary base tables and user-defined tables.

    • C.

      The usernames of all the users including the database administrators are stored in the data dictionary.

    • D.

      The USER_CONS_COLUMNS view should be queried to find the names of the columns to which a constraint applies.

    • E.

      Both USER_OBJECTS and CAT views provide the same information about all the objects that are owned by the user.

    • F.

      Views with the same name but different prefixes, such as DBA, ALL and USER, use the same base tables from the data dictionary.

    Correct Answer(s)
    C. The usernames of all the users including the database administrators are stored in the data dictionary.
    D. The USER_CONS_COLUMNS view should be queried to find the names of the columns to which a constraint applies.
    F. Views with the same name but different prefixes, such as DBA, ALL and USER, use the same base tables from the data dictionary.
  • 49. 

    View the exhibits and examine the structures of the COSTS and PROMOTIONS tables. Evaluate the following SQL statement: SQL> SELECT prod_id FROM costs WHERE promo_id IN (SELECT promo_id FROM promotions WHERE promo_cost < ALL (SELECT MAX(promo_cost) FROM promotions GROUP BY (promo_end_datepromo_ begin_date))); What would be the outcome of the above SQL statement?

    • A.

      It displays prod IDs in the promo with the lowest cost.

    • B.

      It displays prod IDs in the promos with the lowest cost in the same time interval.

    • C.

      T displays prod IDs in the promos with the highest cost in the same time interval.

    • D.

      It displays prod IDs in the promos which cost less than the highest cost in the same time interval.

    Correct Answer
    D. It displays prod IDs in the promos which cost less than the highest cost in the same time interval.
  • 50. 

    View the exhibit and examine the descriptions of the DEPT and LOCATIONS tables. You want to update the CITY column of the DEPT table for all the rows with the corresponding value in the CITY column of the LOCATIONS table for each department. Which SQL statement would you execute to accomplish the task?

    • A.

      UPDATE dept d SET city = ALL (SELECT city FROM locations l WHERE d.location_id = l.location_id);

    • B.

      UPDATE dept d SET city = (SELECT city FROM locations l) WHERE d.location_id = l.location_id;

    • C.

      UPDATE dept d SET city = ANY (SELECT city FROM locations l)

    • D.

      UPDATE dept d SET city = (SELECT city FROM locations l WHERE d.location_id = l.location_id);

    Correct Answer
    D. UPDATE dept d SET city = (SELECT city FROM locations l WHERE d.location_id = l.location_id);

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 28, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Sep 26, 2018
    Quiz Created by
    Melissajanuary

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.