Oracle SQL Expert Certification - Part II

Description

dalsi otazky ze souboru
Jan Kubec
Quiz by Jan Kubec, updated more than 1 year ago
Jan Kubec
Created by Jan Kubec almost 11 years ago
555
3

Resource summary

Question 1

Question
Evaluate the following ALTER TABLE statement: ALTER TABLE orders SET UNUSED order_date; Which statement is true?
Answer
  • The DESCRIBE command would still display the ORDER_DATE column.
  • ROLLBACK can be used to get back the ORDER_DATE column in the ORDERS table.
  • The ORDER_DATE column should be empty for the ALTER TABLE command to execute successfully.
  • After executing the ALTER TABLE command, you can add a new column called ORDER_DATE to the ORDERS table.

Question 2

Question
View the Exhibit and examine the ORDERS table. 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?
Answer
  • ALTER TABLE orders ADD CONSTRAINT orders_cust_id_nn NOT NULL (customer_id);
  • ALTER TABLE orders MODIFY customer_id CONSTRAINT orders_cust_id_nn NOT NULL;
  • ALTER TABLE orders MODIFY CONSTRAINT orders_cust_id_nn NOT NULL (customer_id);
  • ALTER TABLE orders ADD customer_id NUMBER(6)CONSTRAINT orders_cust_id_nn NOT NULL;

Question 3

Question
Which three statements indicate the end of a transaction? (Choose three.)
Answer
  • after a COMMIT is issued
  • after a ROLLBACK is issued
  • after a SAVEPOINT is issued
  • after a SELECT statement is issued
  • after a CREATE statement is issued

Question 4

Question
View the Exhibit and examine the structure of the ORDERS table. You have to display ORDER_ID, ORDER_DATE, and CUSTOMER_ID for all those orders that were placed after the last order placed by the customer whose CUSTOMER_ID is 101. Which query would give you the desired output?
Answer
  • SELECT order_id, order_date FROM orders WHERE order_date > ALL (SELECT MAX(order_date) FROM orders ) AND customer_id = 101;
  • SELECT order_id, order_date FROM orders WHERE order_date > ANY (SELECT order_date FROM orders WHERE customer_id = 101);
  • SELECT order_id, order_date FROM orders WHERE order_date > ALL (SELECT order_date FROM orders WHERE customer_id = 101);
  • SELECT order_id, order_date FROM orders WHERE order_date IN (SELECT order_date FROM orders WHERE customer_id = 101);

Question 5

Question
You need to create a table with the following column specifications: 1. Employee ID (numeric data type) for each employee 2. Employee Name, (character data type) which stores the employee name 3. Hire date, to store the date when the employee joined the organization 4. Status (character data type). It should contain the value "ACTIVE" if no data is entered. 5. Resume (character large object [CLOB] data type), which would contain the resume submitted by the employee Which is the correct syntax to create this table?
Answer
  • CREATE TABLE EMP_1 (emp_id NUMBER(4), emp_name VARCHAR2(25), start_date DATE, e_status VARCHAR2(10) DEFAULT 'ACTIVE', resume CLOB(200));
  • CREATE TABLE 1_EMP (emp_id NUMBER(4), emp_name VARCHAR2(25), start_date DATE, emp_status VARCHAR2(10) DEFAULT 'ACTIVE', resume CLOB);
  • CREATE TABLE 1_EMP (emp_id NUMBER(4), emp_name VARCHAR2(25), start_date DATE, emp_status VARCHAR2(10) DEFAULT "ACTIVE", resume CLOB);
  • CREATE TABLE EMP_1 (emp_id NUMBER, emp_name VARCHAR2(25), start_date DATE, emp_status VARCHAR2(10) DEFAULT 'ACTIVE', resume CLOB);

Question 6

Question
The details of the order ID, order date, order total, and customer ID are obtained from the ORDERS table. If the order value is more than 30000, the details have to be added to the LARGE_ORDERS table. The order ID, order date, and order total should be added to the ORDER_HISTORY table, and order ID and customer ID should be added to the CUST_HISTORY table. Which multitable INSERT statement would you use?
Answer
  • Pivoting INSERT
  • Unconditional INSERT
  • Conditional ALL INSERT
  • Conditional FIRST INSERT

Question 7

Question
View the Exhibit and examine the description of the EMPLOYEES table. Evaluate the following SQL statement: SELECT first_name, employee_id, NEXT_DAY(ADD_MONTHS(hire_date, 6), 1) "Review" FROM employees; The query was written to retrieve the FIRST_NAME, EMPLOYEE_ID, and review date for employees. The review date is the first Monday after the completion of six months of the hiring. The NLS_TERRITORY parameter is set to AMERICA in the session. Which statement is true regarding this query?
Answer
  • The query would execute to give the desired output.
  • The query would not execute because date functions cannot be nested.
  • The query would execute but the output would give review dates that are Sundays.
  • The query would not execute because the NEXT_DAY function accepts a string as argument.

Question 8

Question
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?
Answer
  • 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;
  • 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;
  • 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;
  • SELECT m.last_name "Manager", e.last_name "Employee" FROM employees m JOIN employees e WHERE m.employee_id = e.manager_id AND e.manager_id=100;

Question 9

Question
View the Exhibit1 and examine the descriptions of the EMPLOYEES and DEPARTMENTS tables. SELECT e.department_id, e.job_id, d.location_id, sum(e.salary) total GROUPING(e.department_id) GRP_DEPT, GROUPING(e.job_id) GRP_JOB, GROUPING(d.location_id) GRP_LOC FROM employees e JOIN departments d ON e.department_id = d.department_id GROUP BY ROLLUP (e.department_id, e.job_id, d.location_id); View the Exhibit2 and examine the output of the command. Which two statements are true regarding the output? (Choose two.)
Answer
  • The value 1 in GRP_LOC means that the LOCATION_ID column is taken into account to generate the subtotal.
  • The value 1 in GRP_JOB and GRP_LOC means that JOB_ID and LOCATION_ID columns are not taken into account to generate the subtotal.
  • The value 1 in GRP_JOB and GRP_LOC means that the NULL value in JOB_ID and LOCATION_ID columns are taken into account to generate the subtotal.
  • The value 0 in GRP_DEPT, GRP_JOB, and GRP_LOC means that DEPARTMENT_ID, JOB_ID, and LOCATION_ID columns are taken into account to generate the subtotal.

Question 10

Question
View the Exhibit and examine the description of the DEPARTMENTS and EMPLOYEES tables. To 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?
Answer
  • The NATURAL JOIN clause is missing the USING clause.
  • The table prefix is missing for the column names in the SELECT clause.
  • The DEPARTMENTS table is not used before the EMPLOYEES table in the FROM clause.
  • The EMPLOYEES and DEPARTMENTS tables have more than one column with the same column name and data type.

Question 11

Question
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?
Answer
  • UPDATE dept d SET city = ANY (SELECT city FROM locations l);
  • UPDATE dept d SET city = (SELECT city FROM locations l) WHERE d.location_id = l.location_id;
  • UPDATE dept d SET city = (SELECT city FROM locations l WHERE d.location_id = l.location_id);
  • UPDATE dept d SET city = ALL (SELECT city FROM locations l WHERE d.location_id = l.location_id);

Question 12

Question
View the Exhibit and examine the data in the LOCATIONS table. Evaluate the following SQL statement: SELECT street_address FROM locations WHERE REGEXP_INSTR(street_address,'[^[:alpha:]]') = 1; Which statement is true regarding the output of this SQL statement?
Answer
  • It would display all the street addresses that do not have a substring 'alpha'.
  • It would display all the street addresses where the first character is a special character.
  • It would display all the street addresses where the first character is a letter of the alphabet.
  • It would display all the street addresses where the first character is not a letter of the alphabet.

Question 13

Question
Evaluate the following expression using meta character for regular expression: '[^Ale|ax.r$]' Which two matches would be returned by this expression? (Choose two.)
Answer
  • Alex
  • Alax
  • Alxer
  • Alaxendar
  • Alexender

Question 14

Question
The ORDERS table belongs to the user OE. OE has granted the SELECT privilege on the ORDERS table to the user HR. Which statement would create a synonym ORD so that HR can execute the following query successfully? SELECT * FROM ord;
Answer
  • CREATE SYNONYM ord FOR orders; This command is issued by OE.
  • CREATE PUBLIC SYNONYM ord FOR orders; This command is issued by OE.
  • CREATE SYNONYM ord FOR oe.orders; This command is issued by the database administrator.
  • CREATE PUBLIC SYNONYM ord FOR oe.orders; This command is issued by the database administrator.

Question 15

Question
View the Exhibit and examine the description of the EMPLOYEES and DEPARTMENTS tables. You want to display the LAST_NAME for the employees, LAST_NAME for the manager of the employees, and the DEPARTMENT_NAME for the employees having 100 as MANAGER_ID. The following SQL statement was written: SELECT m.last_name "Manager", e.last_name "Employee", department_name "Department" FROM employees m JOIN employees e ON (m.employee_id = e.manager_id) WHERE e.manager_id=100 JOIN departments d ON (e.department_id = d.department_id); Which statement is true regarding the output of this SQL statement?
Answer
  • The statement would provide the desired results.
  • The statement would not execute because the ON clause is written twice
  • The statement would not execute because the WHERE clause is wrongly placed.
  • The statement would not execute because the self join uses the ON clause instead of the USING clause.

Question 16

Question
Evaluate the following DELETE statement: DELETE FROM orders; There are no other uncommitted transactions on the ORDERS table. Which statement is true about the DELETE statement?
Answer
  • It removes all the rows in the table and allows ROLLBACK.
  • It would not remove the rows if the table has a primary key.
  • It removes all the rows as well as the structure of the table.
  • It removes all the rows in the table and does not allow ROLLBACK.

Question 17

Question
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?
Answer
  • DELETE order_id FROM orders WHERE order_total < 1000;
  • DELETE orders WHERE order_total < 1000;
  • DELETE FROM orders WHERE (SELECT order_id FROM order_items);
  • DELETE orders o, order_items i WHERE o.order_id = i.order_id;

Question 18

Question
View the Exhibit and examine the description for EMPLOYEES and DEPARTMENTS tables. Evaluate the following SQL statement: SELECT e.department_id, e.job_id, d.location_id, sum(e.salary) total FROM employees e JOIN departments d ON e.department_id = d.department_id GROUP BY CUBE (e.department_id, e.job_id, d.location_id); Which two statements are true regarding the output of this command? (Choose two.)
Answer
  • The output would display the total salary for all the departments.
  • The output would display the total salary for all the JOB_IDs in a department.
  • The output would display only the grand total of the salary for all JOB_IDs in a LOCATION_ID.
  • The output would display the grand total of the salary for only the groups specified in the GROUP BY clause.

Question 19

Question
View the Exhibit and examine the data in EMP and DEPT tables. In the DEPT table, DEPTNO is the PRIMARY KEY. In the EMP table, EMPNO is the PRIMARY KEY and DEPTNO is the FOREIGN KEY referencing the DEPTNO column in the DEPT table. What would be the outcome of the following statements executed in the given sequence? DROP TABLE emp; FLASHBACK TABLE emp TO BEFORE DROP; INSERT INTO emp VALUES (2,COTT 10); INSERT INTO emp VALUES (3,ING 55);
Answer
  • Both the INSERT statements would fail because all constraints are automatically retrieved when the table is flashed back.
  • Both the INSERT statements would succeed because none of the constraints on the table are automatically retrieved when the table is flashed back.
  • Only the first INSERT statement would succeed because all the constraints except the primary key constraint are automatically retrieved after a table is flashed back.
  • Only the second INSERT statement would succeed because all the constraints except referential integrity constraints that reference other tables are retrieved automatically after the table is flashed back.

Question 20

Question
View the Exhibit and examine the structure of the ORDERS table. The ORDER_ID column is the PRIMARY KEY in the ORDERS table. Evaluate the following CREATE TABLE command: CREATE TABLE new_orders(ord_id, ord_date DEFAULT SYSDATE, cust_id) AS SELECT order_id,order_date,customer_id FROM orders; Which statement is true regarding the above command?
Answer
  • The NEW_ORDERS table would not get created because the DEFAULT value cannot be specified in the column definition.
  • The NEW_ORDERS table would get created and only the NOT NULL constraint defined on the specified columns would be passed to the new table.
  • The NEW_ORDERS table would not get created because the column names in the CREATE TABLE command and the SELECT clause do not match.
  • The NEW_ORDERS table would get created and all the constraints defined on the specified columns in the ORDERS table would be passed to the new table.

Question 21

Question
Which two statements are true regarding the GROUP BY clause in a SQL statement? (Choose two.)
Answer
  • You can use column alias in the GROUP BY clause.
  • Using the WHERE clause after the GROUP BY clause excludes the rows after creating groups.
  • The GROUP BY clause is mandatory if you are using an aggregate function in the SELECT clause.
  • Using the WHERE clause before the GROUP BY clause excludes the rows before creating groups.
  • 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 clause.

Question 22

Question
Which statement is true regarding synonyms?
Answer
  • Synonyms can be created for tables but not views.
  • Synonyms are used to reference only those tables that are owned by another user.
  • A public synonym and a private synonym can exist with the same name for the same table.
  • The DROP SYNONYM statement removes the synonym, and the status of the table on which the synonym has been created becomes invalid.

Question 23

Question
Evaluate the following command: CREATE TABLE employees CREATE TABLE employees (employee_id NUMBER(2) PRIMARY KEY, last_name VARCHAR2(25) NOT NULL, department_id NUMBER(2), job_id VARCHAR2(8), salary NUMBER(10,2)); You issue the following command to create a view that displays the IDs and last names of the sales staff in the organization: CREATE OR REPLACE VIEW sales_staff_vu AS SELECT employee_id, last_name,job_id FROM employees WHERE job_id LIKE 'SA_%' WITH CHECK OPTION; Which statements are true regarding the above view? (Choose all that apply.)
Answer
  • It allows you to insert details of all new staff into the EMPLOYEES table.
  • It allows you to delete the details of the existing sales staff from the EMPLOYEES table.
  • It allows you to update the job ids of the existing sales staff to any other job id in the EMPLOYEES table.
  • It allows you to insert the IDs, last names and job ids of the sales staff from the view if it is used in multitable INSERT statements.

Question 24

Question
View the Exhibit and examine the structure of EMPLOYEES and JOB_HISTORY tables. The EMPLOYEES table maintains the most recent information regarding salary, department, and job for all the employees. The JOB_HISTORY table maintains the record for all the job changes for the employees. You want to delete all the records from the JOB_HISTORY table that are repeated in the EMPLOYEES table. Which two SQL statements can you execute to accomplish the task? (Choose two.)
Answer
  • DELETE FROM job_history j WHERE employee_id = (SELECT employee_id FROM employees e WHERE j.employee_id = e.employee_id) AND job_id = (SELECT job_id FROM employees e WHERE j.job_id = e.job_id);
  • DELETE FROM job_history j WHERE (employee_id, job_id) = ALL (SELECT employee_id, job_id FROM employees e WHERE j.employee_id = e.employee_id and j.job_id = e.job_id )
  • DELETE FROM job_history j WHERE employee_id = (SELECT employee_id FROM employees e WHERE j.employee_id = e.employee_id and j.job_id = e.job_id )
  • DELETE FROM job_history j WHERE (employee_id, job_id) = (SELECT employee_id, job_id FROM employees e WHERE j.employee_id = e.employee_id and j.job_id = e.job_id )

Question 25

Question
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?
Answer
  • PUBLIC should be replaced with specific usernames.
  • ALL should be replaced with a list of specific privileges.
  • WITH GRANT OPTION should be added to the statement.
  • Separate GRANT statements are required for ORDERS and ORDER_ITEMS tables.

Question 26

Question
Given below is a list of functions and the tasks performed by using these functions, in random order. Function Usage 1) LPAD a) Used to truncate a column, expression, or value to n decimal places 2) TRUNC b) Used to remove heading or trailing or both characters from the character string 3) DECODE c) Pads the character value right-justified to a total width of n character positions 4) TRIM d) Used to return the numeric value for position of a named character from the character string 5) INSTR e) Used to translate an expression after comparing it with each search value Which option correctly matches the function names with their usage?
Answer
  • 1-c, 2-b, 3-e, 4-a, 5-d
  • 1-e, 2-b, 3-c, 4-a, 5-d
  • 1-e, 2-a, 3-c, 4-d, 5-b
  • 1-c, 2-a, 3-e, 4-b, 5-d

Question 27

Question
Which statement is true regarding the CUBE operator in the GROUP BY clause of a SQL statement?
Answer
  • It produces only aggregates for the groups specified in the GROUP BY clause.
  • It finds all the NULL values in the superaggregates for the groups specified in the GROUP BY clause.
  • It produces 2 n possible superaggregate combinations, if the n columns and expressions are specified in the GROUP BY clause.
  • It produces n+1 possible superaggregate combinations, if the n columns and expressions are specified in the GROUP BY clause.

Question 28

Question
Which statement is true regarding the SESSION_PRIVS dictionary view?
Answer
  • It contains the current object privileges available in the user session.
  • It contains the current system privileges available in the user session.
  • It contains the object privileges granted to other users by the current user session.
  • It contains the system privileges granted to other users by the current user session.

Question 29

Question
View the Exhibit and examine the details for the CATEGORIES_TAB table. Evaluate the following incomplete SQL statement: SELECT category_name,category_description FROM categories_tab You want to display only the rows that have 'harddisks' as part of the string in the CATEGORY_DESCRIPTION column. Which two WHERE clause options can give you the desired result? (Choose two.)
Answer
  • WHERE REGEXP_LIKE (category_description, 'hard+.s');
  • WHERE REGEXP_LIKE (category_description, '^H|hard+.s');
  • WHERE REGEXP_LIKE (category_description, '^H|hard+.s$');
  • WHERE REGEXP_LIKE (category_description, '[^H|hard+.s]');

Question 30

Question
Which two statements are true regarding roles? (Choose two.)
Answer
  • A role can be granted to itself.
  • A role can be granted to PUBLIC.
  • A user can be granted only one role at any point of time.
  • The REVOKE command can be used to remove privileges but not roles from other users.
  • Roles are named groups of related privileges that can be granted to users or other roles.

Question 31

Question
View the Exhibit and examine the data in the CUST_DET table. INSERT FIRST WHEN credit_limit >= 5000 THEN INTO cust_1 VALUES(cust_id, credit_limit, grade, gender) WHEN grade = THEN INTO cust_2 VALUES(cust_id, credit_limit, grade, gender) WHEN grade = THEN INTO cust_3 VALUES(cust_id, credit_limit, grade, gender) INTO cust_4 VALUES(cust_id, credit_limit, grade, gender) ELSE INTO cust_5 VALUES(cust_id, credit_limit, grade, gender) SELECT * FROM cust_det; The row will be inserted in _______.
Answer
  • CUST_1 table only because CREDIT_LIMIT condition is satisfied
  • CUST_1 and CUST_2 tables because CREDIT_LIMIT and GRADE conditions are satisfied
  • CUST_1,CUST_2 and CUST_5 tables because CREDIT_LIMIT and GRADE conditions are satisfied but GENDER condition is not satisfied
  • CUST_1, CUST_2 and CUST_4 tables because CREDIT_LIMIT and GRADE conditions are satisfied for CUST_1 and CUST_2, and CUST_4 has no condition on it

Question 32

Question
View the Exhibit and examine the data in the EMPLOYEES tables. SELECT employee_id, department_id FROM employees WHERE department_id= 50 ORDER BY department_id UNION SELECT employee_id, department_id FROM employees WHERE department_id= 90 UNION SELECT employee_id, department_id FROM employees WHERE department_id= 10; What would be the outcome of the above SQL statement?
Answer
  • The statement would execute successfully and display all the rows in the ascending order of DEPARTMENT_ID.
  • The statement would execute successfully but it will ignore the ORDER BY clause and display the rows in random order.
  • The statement would not execute because the positional notation instead of the column name should be used with the ORDER BY clause.
  • The statement would not execute because the ORDER BY clause should appear only at the end of the SQL statement, that is, in the last SELECT statement.

Question 33

Question
Evaluate the SQL statements: CREATE TABLE new_order (orderno NUMBER(4), booking_date TIMESTAMP WITH LOCAL TIME ZONE); The database is located in San Francisco where the time zone is -8:00. The user is located in New York where the time zone is -5:00. A New York user inserts the following record: INSERT INTO new_order VALUES(1, TIMESTAMP ?007-05-10 6:00:00 -5:00?); Which statement is true?
Answer
  • When the New York user selects the row, booking_date is displayed as '007-05-10 3.00.00.000000'
  • When the New York user selects the row, booking_date is displayed as '2007-05-10 6.00.00.000000 - 5:00'.
  • When the San Francisco user selects the row, booking_date is displayed as '007-05-10 3.00.00.000000'
  • When the San Francisco user selects the row, booking_date is displayed as '007-05-10 3.00.00.000000 - 8:00'

Question 34

Question
Which statements are true? (Choose all that apply.)
Answer
  • The data dictionary is created and maintained by the database administrator.
  • The data dictionary views can consist of joins of dictionary base tables and user-defined tables.
  • The usernames of all the users including the database administrators are stored in the data dictionary.
  • The USER_CONS_COLUMNS view should be queried to find the names of the columns to which a constraint applies.
  • Both USER_OBJECTS and CAT views provide the same information about all the objects that are owned by the user
  • Views with the same name but different prefixes, such as DBA, ALL and USER, use the same base tables from the data dictionary

Question 35

Question
View the Exhibit and examine the details of the PRODUCT_INFORMATION table. You have the requirement to display PRODUCT_NAME and LIST_PRICE 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, list_price 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?
Answer
  • It would execute but the output would return no rows.
  • It would execute and the output would display the desired result.
  • It would not execute because the entire WHERE clause condition is not enclosed within the parentheses.
  • It would not execute because the same column has been used in both sides of the AND logical operator to form the condition.

Question 36

Question
Given below is the list of meta character syntaxes and their descriptions in random order: Meta character syntax Description 1) ^ a) Matches character not in the list 2) [^...] b) Matches character when it occurs at the beginning of a line 3) | c) Treats the subsequent meta character as a literal 4) \ d) Matches one of the characters such as the OR operator Identify the option that correctly matches the meta character syntaxes with their descriptions.
Answer
  • 1-b, 2-a, 3-d, 4-c
  • 1-a, 2-b, 3-d, 4-c
  • 1-d, 2-b, 3-a, 4-c
  • 1-b, 2-c, 3-d, 2-a

Question 37

Question
View the Exhibit and examine the structure of ORDERS and CUSTOMERS tables. Evaluate the following UPDATE statement: UPDATE (SELECT order_date, order_total, customer_id FROM orders) SET order_date = '22-mar-2007' WHERE customer_id = (SELECT customer_id FROM customers WHERE cust_last_name = 'Roberts' AND credit_limit = 600); Which statement is true regarding the execution of the above UPDATE statement?
Answer
  • It would not execute because two tables cannot be used in a single UPDATE statement.
  • It would execute and restrict modifications to only the columns specified in the SELECT statement.
  • It would not execute because a subquery cannot be used in the WHERE clause of an UPDATE statement.
  • It would not execute because the SELECT statement cannot be used in place of the table name.

Question 38

Question
Which statement correctly differentiates a system privilege from an object privilege?
Answer
  • System privileges can be granted only by the DBA whereas object privileges can be granted by DBAs or the owner of the object.
  • System privileges give the rights to only create user schemas whereas object privileges give rights to manipulate objects in a schema.
  • Users require system privileges to gain access to the database whereas they require object privileges to create objects in the database.
  • A system privilege is the right to perform specific activities in a database whereas an object privilege is a right to perform activities on a specific object in the database.

Question 39

Question
View the Exhibit and examine the data in the PRODUCT_INFORMATION table. Which two tasks would require subqueries? (Choose two.)
Answer
  • displaying the minimum list price for each product status
  • displaying all supplier IDs whose average list price is more than 500
  • displaying the number of products whose list prices are more than the average list price
  • displaying all the products whose minimum list prices are more than the average list price of products having the product status orderable
  • displaying the total number of products supplied by supplier 102071 and having product status OBSOLETE

Question 40

Question
Which two statements are true regarding constraints? (Choose two.)
Answer
  • A foreign key cannot contain NULL values.
  • A column with the UNIQUE constraint can contain NULL.
  • A constraint is enforced only for the INSERT operation on a table.
  • A constraint can be disabled even if the constraint column contains data.
  • All the constraints can be defined at the column level as well as the table level.

Question 41

Question
View the Exhibit and examine the description of the ORDER_ITEMS table. The following SQL statement was written to retrieve the rows for the PRODUCT_ID that has a UNIT_PRICE of more than 1,000 and has been ordered more than five times: SELECT product_id, COUNT(order_id) total, unit_price FROM order_items WHERE unit_price>1000 AND COUNT(order_id)>5 GROUP BY product_id, unit_price; Which statement is true regarding this SQL statement?
Answer
  • The statement would execute and give you the desired result.
  • The statement would not execute because the aggregate function is used in the WHERE clause.
  • The statement would not execute because the WHERE clause should have the OR logical operator instead of AND.
  • The statement would not execute because in the SELECT clause, the UNIT_PRICE column is placed after the column having the aggregate function.

Question 42

Question
Which two statements best describe the benefits of using the WITH clause? (Choose two.)
Answer
  • It enables users to store the results of a query permanently.
  • It enables users to store the query block permanently in the memory and use it to create complex queries.
  • It enables users to reuse the same query block in a SELECT statement, if it occurs more than once in a complex query.
  • It can improve the performance of a large query by storing the result of a query block having the WITH clause in the user's temporary tablespace.

Question 43

Question
View the Exhibit and examine the structure of the ORDERS and ORDER_ITEMS tables. In the ORDERS table, ORDER_ID is the PRIMARY KEY and ORDER_DATE has the DEFAULT value as SYSDATE. Evaluate the following statement: UPDATE orders SET order_date=DEFAULT WHERE order_id IN (SELECT order_id FROM order_items WHERE qty IS NULL); What would be the outcome of the above statement?
Answer
  • The UPDATE statement would not work because the main query and the subquery use different tables.
  • The UPDATE statement would not work because the DEFAULT value can be used only in INSERT statements.
  • The UPDATE statement would change all ORDER_DATE values to SYSDATE provided the current ORDER_DATE is NOT NULL and QTY is NULL.
  • The UPDATE statement would change all the ORDER_DATE values to SYSDATE irrespective of what the current ORDER_DATE value is for all orders where QTY is NULL.

Question 44

Question
View the Exhibit and examine the description of the EMPLOYEES table. Evaluate the following SQL statement: SELECT employee_id, last_name, job_id, manager_id, LEVEL FROM employees START WITH employee_id = 101 CONNECT BY PRIOR employee_id=manager_id ; Which two statements are true regarding the output of this command? (Choose two.)
Answer
  • The output would be in top-down hierarchy starting with EMPLOYEE_ID having value 101.
  • The output would be in bottom-up hierarchy starting with EMPLOYEE_ID having value 101.
  • The LEVEL column displays the number of employees in the hierarchy under the employee having the EMPLOYEE_ID 101.
  • The LEVEL column displays the level in the hierarchy at which the employee is placed under the employee having the EMPLOYEE_ID 101.

Question 45

Question
Which three statements are true regarding the WHERE and HAVING clauses in a SQL statement? (Choose three.)
Answer
  • The HAVING clause conditions can have aggregate functions.
  • The HAVING clause conditions can use aliases for the columns.
  • WHERE and HAVING clauses cannot be used together in a SQL statement.
  • The WHERE clause is used to exclude rows before the grouping of data.
  • The HAVING clause is used to exclude one or more aggregated results after grouping data.

Question 46

Question
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?
Answer
  • It recovers only the table structure
  • It recovers the table structure, data, and the indexes.
  • It recovers the table structure and data but not the related indexes.
  • It is not possible to recover the table structure, data, or the related indexes.

Question 47

Question
Which statements are true regarding the usage of the WITH clause in complex correlated subqueries? (Choose all that apply.)
Answer
  • It can be used only with the SELECT clause.
  • The WITH clause can hold more than one query.
  • If the query block name and the table name were the same, then the table name would take precedence
  • The query name in the WITH clause is visible to other query blocks in the WITH clause as well as to the main query block.

Question 48

Question
Evaluate the following SQL statement: CREATE INDEX upper_name_idx ON product_information(UPPER(product_name)); Which query would use the UPPER_NAME_IDX index?
Answer
  • SELECT UPPER(product_name) FROM product_information WHERE product_id = 2254;
  • SELECT UPPER(product_name) FROM product_information;
  • SELECT product_id FROM product_information WHERE UPPER(product_name) IN ('LASERPRO', 'Cable');
  • SELECT product_id, UPPER(product_name) FROM product_information WHERE UPPER(product_name)='LASERPRO' OR list_price > 1000;

Question 49

Question
Which three statements are true regarding group functions? (Choose three.)
Answer
  • They can be used on columns or expressions.
  • They can be passed as an argument to another group function.
  • They can be used only with a SQL statement that has the GROUP BY clause.
  • They can be used on only one column in the SELECT clause of a SQL statement.
  • They can be used along with the single-row function in the SELECT clause of a SQL statement.

Question 50

Question
Which three statements are true regarding single-row functions? (Choose three.)
Answer
  • They can accept only one argument.
  • They can be nested up to only two levels.
  • They can return multiple values of more than one data type.
  • They can be used in SELECT, WHERE, and ORDER BY clauses.
  • They can modify the data type of the argument that is referenced
  • They can accept a column name, expression, variable name, or a user-supplied constant as arguments.

Question 51

Question
Which view would you use to display the column names and DEFAULT values for a table?
Answer
  • DBA_TABLES
  • DBA_COLUMNS
  • USER_COLUMNS
  • USER_TAB_COLUMNS

Question 52

Question
View the Exhibit and examine the structure for the ORDERS and ORDER_ITEMS tables. You want to display ORDER_ID, PRODUCT_ID, and TOTAL (UNIT_PRICE multiplied by QUANTITY) for all the orders placed in the last seven days. Which query would you execute?
Answer
  • SELECT order_id, product_id, unit_price*quantity "TOTAL" FROM order_items oi JOIN orders o ON (o.order_id=oi.order_id) WHERE o.order_date>=SYSDATE-7;
  • SELECT o.order_id,oi.product_id, oi.unit_price*oi.quantity " TOTAL" FROM order_items oi JOIN orders o USING (order_id) WHERE o.order_date>=SYSDATE-7;
  • SELECT o.order_id, oi.product_id, oi.unit_price*oi.quantity "TOTAL" FROM order_items oi JOIN orders o WHERE o.order_date>=SYSDATE-7 ON (o.order_id=oi.order_id);
  • SELECT o.order_id, oi.product_id, oi.unit_price*oi.quantity "TOTAL" FROM order_items oi JOIN orders o ON (o.order_id=oi.order_id) WHERE o.order_date>=SYSDATE-7;

Question 53

Question
Which three statements are true? (Choose three.)
Answer
  • Only one LONG column can be used per table.
  • A TIMESTAMP data type column stores only time values with fractional seconds.
  • The BLOB data type column is used to store binary data in an operating system file.
  • The minimum column width that can be specified for a varchar2 data type column is one.
  • The value for a CHAR data type column is blank-padded to the maximum defined column width.

Question 54

Question
Which two statements are true regarding subqueries? (Choose two.)
Answer
  • Only two subqueries can be placed at one level.
  • A subquery can be used to access data from one or more tables or views.
  • If the subquery returns 0 rows, then the value returned by the subquery expression is NULL.
  • The columns in a subquery must always be qualified with the name or alias of the table used.
  • A subquery in the WHERE clause of a SELECT statement can be nested up to three levels only.

Question 55

Question
View the Exhibit and examine the description of the PRODUCT_INFORMATION table. SELECT product_name, list_price, min_price, list_price - min_price Difference FROM product_information; Which options when used with the above SQL statement can produce the sorted output in ascending order of the price difference between LIST_PRICE and MIN_PRICE? (Choose all that apply.)
Answer
  • ORDER BY 4
  • ORDER BY MIN_PRICE
  • ORDER BY DIFFERENCE
  • ORDER BY LIST_PRICE
  • ORDER BY LIST_PRICE - MIN_PRICE

Question 56

Question
Evaluate the following statement: INSERT ALL WHEN order_total < 10000 THEN INTO small_orders WHEN order_total > 10000 AND order_total < 20000 THEN INTO medium_orders WHEN order_total > 2000000 THEN INTO large_orders SELECT order_id, order_total, customer_id FROM orders; Which statement is true regarding the evaluation of rows returned by the subquery in the INSERT statement?
Answer
  • They are evaluated by all the three WHEN clauses regardless of the results of the evaluation of any other WHEN clause.
  • They are evaluated by the first WHEN clause. If the condition is true, then the row would be evaluated by the subsequent WHEN clauses.
  • They are evaluated by the first WHEN clause. If the condition is false, then the row would be evaluated by the subsequent WHEN clauses.
  • The INSERT statement would give an error because the ELSE clause is not present for support in case none of the WHEN clauses are true.

Question 57

Question
Which three possible values can be set for the TIME_ZONE session parameter by using the ALTER SESSION command? (Choose three.)
Answer
  • 'os'
  • local
  • '-8:00'
  • dbtimezone
  • 'Australia'

Question 58

Question
View the Exhibit and examine the structure of the ORDER_ITEMS table. Examine the following SQL statement: SELECT order_id, product_id, unit_price FROM order_items WHERE unit_price = (SELECT MAX(unit_price) FROM order_items GROUP BY order_id); You want to display the PRODUCT_ID of the product that has the highest UNIT_PRICE per ORDER_ID. What correction should be made in the above SQL statement to achieve this?
Answer
  • Replace = with the IN operator.
  • Replace = with the >ANY operator.
  • Replace = with the >ALL operator.
  • Remove the GROUP BY clause from the subquery and place it in the main query.

Question 59

Question
View the Exhibit and examine the table structure of DEPARTMENTS and LOCATIONS tables. You want to display all the cities that have no departments and the departments that have not been allocated cities. Which type of join between DEPARTMENTS and LOCATIONS tables would produce this information as part of its output?
Answer
  • NATURAL JOIN
  • FULL OUTER JOIN
  • LEFT OUTER JOIN
  • RIGHT OUTER JOIN

Question 60

Question
View the Exhibit and examine the description of the ORDERS table. Your manager asked you to get the SALES_REP_ID and the total numbers of orders placed by each of the sales representatives. Which statement would provide the desired result?
Answer
  • SELECT sales_rep_id, COUNT(order_id) total_orders FROM orders GROUP BY sales_rep_id;
  • SELECT sales_rep_id, COUNT(order_id) total_orders FROM orders GROUP BY sales_rep_id, total_orders;
  • SELECT sales_rep_id, COUNT(order_id) total_orders FROM orders;
  • SELECT sales_rep_id, COUNT(order_id) total_orders FROM orders WHERE sales_rep_id IS NOT NULL;

Question 61

Question
View the Exhibit and examine the structure of ORDERS and CUSTOMERS tables. Which INSERT statement should be used to add a row into the ORDERS table for the customer whose CUST_LAST_NAME is Roberts and CREDIT_LIMIT is 600?
Answer
  • INSERT INTO orders VALUES (1,'10-mar-2007', 'direct', (SELECT customer_id FROM customers WHERE cust_last_name='Roberts' AND credit_limit=600), 1000);
  • INSERT INTO orders (order_id,order_date,order_mode, (SELECT customer_id FROM customers WHERE cust_last_name='Roberts' AND credit_limit=600),order_total) VALUES(1,'10-mar-2007', 'direct', &&customer_id, 1000);
  • INSERT INTO orders (order_id,order_date,order_mode, (SELECT customer_id FROM customers WHERE cust_last_name='Roberts' AND credit_limit=600),order_total) VALUES(1,'10-mar-2007', 'direct', &customer_id, 1000);
  • INSERT INTO(SELECT o.order_id, o.order_date,o.order_mode,c.customer_id, order_total FROM orders o, customers c WHERE o.customer_id = c.customer_id AND c.cust_last_name='Roberts' ANDc.credit_limit=600 ) VALUES (1,'10-mar-2007', 'direct',(SELECT customer_id FROM customers WHERE cust_last_name='Roberts' AND credit_limit=600), 1000);

Question 62

Question
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?
Answer
  • Enclose the character literal string in the SELECT clause within the double quotation marks.
  • Do not enclose the character literal string in the SELECT clause within the single quotation marks.
  • Use Quote (q) operator and delimiter to allow the use of single quotation mark in the literal character string.
  • Use escape character to negate the single quotation mark inside the literal character string in the SELECT clause.

Question 63

Question
View the Exhibit and examine the data in EMPLOYEES and DEPARTMENTS tables. In the EMPLOYEES table EMPLOYEE_ID is the PRIMARY KEY and DEPARTMENT_ID is the FOREIGN KEY. In the DEPARTMENTS table DEPARTMENT_ID is the PRIMARY KEY. Evaluate the following UPDATE statement: UPDATE employees a SET department_id = (SELECT department_id FROM departments WHERE location_id = '2100'), (salary, commission_pct) = (SELECT 1.1*AVG(salary), 1.5*AVG(commission_pct) FROM employees b WHERE a.department_id = b.department_id) WHERE first_name||' '||last_name = 'Amit Banda'; What would be the outcome of the above statement? What would be the outcome of the above statement?
Answer
  • It would execute successfully and update the relevant data.
  • It would not execute successfully because there is no LOCATION_ID 2100 in the DEPARTMENTS table.
  • It would not execute successfully because the condition specified with the concatenation operator is not valid.
  • It would not execute successfully because multiple columns (SALARY,COMMISSION_PCT)cannot be used in an UPDATE statement.

Question 64

Question
View the Exhibit and examine the description of the ORDERS table. You need to display CUSTOMER_ID for all customers who have placed orders more than three times in the last six months. You issued the following SQL statement: SELECT customer_id,COUNT(order_id) FROM orders WHERE COUNT(order_id)>3 AND order_date BETWEEN ADD_MONTHS(SYSDATE,-6) AND SYSDATE GROUP BY customer_id; Which statement is true regarding the execution of the above statement?
Answer
  • It would execute successfully and provide the desired result.
  • It would not execute because the WHERE clause cannot have an aggregate function.
  • It would not execute because the ORDER_ID column is not included in the GROUP BY clause.
  • It would not execute because the GROUP BY clause should be placed before the WHERE clause.

Question 65

Question
View the Exhibit and examine the data in the PRODUCTS table. Which statement would add a column called PRICE, which cannot contain NULL?
Answer
  • ALTER TABLE products ADD price NUMBER(8,2) NOT NULL;
  • ALTER TABLE products ADD price NUMBER(8,2) DEFAULT NOT NULL;
  • ALTER TABLE products ADD price NUMBER(8,2) DEFAULT 0 NOT NULL;
  • ALTER TABLE products ADD price NUMBER(8,2) DEFAULT CONSTRAINT p_nn NOT NULL;

Question 66

Question
View the Exhibit and examine the structure of the ORD table. Evaluate the following SQL statements that are executed in a user session in the specified order: CREATE SEQUENCE ord_seq; SELECT ord_seq.nextval FROM dual; INSERT INTO ord VALUES (ord_seq.CURRVAL, '25-jan-2007',101); UPDATE ord SET ord_no= ord_seq.NEXTVAL WHERE cust_id =101; What would be the outcome of the above statements?
Answer
  • All the statements would execute successfully and the ORD_NO column would contain the value 2 for the CUST_ID 101.
  • The CREATE SEQUENCE command would not execute because the minimum value and maximum value for the sequence have not been specified.
  • The CREATE SEQUENCE command would not execute because the starting value of the sequence and the increment value have not been specified.
  • All the statements would execute successfully and the ORD_NO column would have the value 20 for the CUST_ID 101 because the default CACHE value is 20.

Question 67

Question
ORD is a private synonym for the OE.ORDERS table. The user OE issues the following command: DROP SYNONYM ord; Which statement is true regarding the above SQL statement?
Answer
  • Only the synonym would be dropped.
  • The synonym would be dropped and the corresponding table would become invalid.
  • The synonym would be dropped and the packages referring to the synonym would be dropped.
  • The synonym would be dropped and any PUBLIC synonym with the same name becomes invalid.

Question 68

Question
View the Exhibit and examine the structure of the ORDERS table. Which task would require subqueries?
Answer
  • displaying the total order value for sales representatives 161 and 163
  • displaying the order total for sales representative 161 in the year 1999
  • displaying the number of orders that have order mode online and order date in 1999
  • displaying the number of orders whose order total is more than the average order total for all online orders

Question 69

Question
View the Exhibit and examine the details of the EMPLOYEES table. Evaluate the following SQL statements: Statement 1: SELECT employee_id, last_name, job_id, manager_id FROM employees START WITH employee_id = 101 CONNECT BY PRIOR employee_id = manager_id AND manager_id != 108 ; Statement 2: SELECT employee_id, last_name, job_id, manager_id FROM employees WHERE manager_id != 108 START WITH employee_id = 101 CONNECT BY PRIOR employee_id = manager_id; Which two statements are true regarding the above SQL statements? (Choose two.)
Answer
  • Statement 2 would not execute because the WHERE clause condition is not allowed in a statement that has the START WITH clause.
  • The output for statement 1 would display the employee with MANAGER_ID 108 and all the employees below him or her in the hierarchy.
  • The output of statement 1 would neither display the employee with MANAGER_ID 108 nor any employee below him or her in the hierarchy.
  • The output for statement 2 would not display the employee with MANAGER_ID 108 but it would display all the employees below him or her in the hierarchy.

Question 70

Question
Which SQL statement would display the view names and definitions of all the views owned by you?
Answer
  • SELECT view_name, text FROM user_view;
  • SELECT view_name, text FROM user_object ;
  • SELECT view_name, text FROM user_objects;
  • SELECT view_name, text FROM user_views;

Question 71

Question
View the Exhibit button and examine the structures of ORDERS and ORDER_ITEMS tables. In the ORDERS table, ORDER_ID is the PRIMARY KEY and in the ORDER_ITEMS table, ORDER_ID and LINE_ITEM_ID form the composite primary key. Which view can have all the DML operations performed on it?
Answer
  • CREATE VIEW V1 AS SELECT order_id, product_id FROM order_items;
  • CREATE VIEW V4(or_no, or_date, cust_id) AS SELECT order_id, order_date, customer_id FROM orders WHERE order_date < '30-mar-2007' WITH CHECK OPTION;
  • CREATE VIEW V3 AS SELECT o.order_id, o.customer_id, i.product_id FROM orders o, order_items i WHERE o.order_id=i.order_id;
  • CREATE VIEW V2 AS SELECT order_id, line_item_id, unit_price*quantity total FROM order_items;
Show full summary Hide full summary

Similar

Basic Physics Concepts
Andrea Leyden
The Great Gatsby: Chapter Summaries
Andrew_Ellinas
CHEMISTRY C1 3
x_clairey_x
A Level: English language and literature technique = Dramatic terms
Jessica 'JessieB
My SMART School Year Goals for 2015
Stephen Lang
Hitler's Chancellorship
c7jeremy
Chemistry unit 2
36jessieh
Plant and animal cells
Tyra Peters
The Berlin Crisis
Alina A
Meteorologia I
Adriana Forero
Salesforce Admin 201 Exam Chunk 3 (66-90)
Brianne Wright