Home
41.
Consider the following UPDATE statement. Which UPDATE statements from the following options will accomplish the same task? (Choose two.)
UPDATE ACCOUNTS
SET LAST_UPDATED = SYSDATE,
UPDATE_USER = USER;
  • A.
    UPDATE ACCOUNTS SET (LAST_UPDATED, UPDATE_USER) = (SYSDATE, USER);
  • B.
    UPDATE ACCOUNTS SET LAST_UPDATED = (SELECT SYSDATE FROM DUAL), UPDATE_USER = (SELECT USER FROM DUAL);
  • C.
    UPDATE ACCOUNTS SET (LAST_UPDATED, UPDATE_USER) = (SELECT SYSDATE, USER FROM DUAL);
  • D.
    UPDATE ACCOUNTS SET LAST_UPDATED = SYSDATE AND UPDATE_USER = USER;
  • Answer & Explanation
  • Report
Answer : [B, C]
Explanation :
Option A will error out because when columns are used in SET, a subquery must be used as in option C. Option D is wrong because AND is used instead of a comma to separate columns in the SET clause.
Report
Name Email  
42.
Which of the following statements do not end a transaction? (Choose two.)
  • A.
    SELECT
  • B.
    COMMIT
  • C.
    TRUNCATE TABLE
  • D.
    UPDATE
  • Answer & Explanation
  • Report
Answer : [A, D]
Explanation :
COMMIT, ROLLBACK, and any DDL statement end a transaction—DDL is automatically committed. INSERT, UPDATE, and DELETE statements require a commit or rollback.
Report
Name Email  
43.
Sara wants to update the SALARY column in the OLD_EMPLOYEES table with the value from the EMPLOYEES table for employees in department 90. Which SQL code will accomplish the task?
  • A.
    UPDATE old_employees a SET salary = (SELECT salary FROM employees b WHERE a.employee_id = b.employee_id) WHERE department_id = 90;
  • B.
    UPDATE old_employees SET salary = (SELECT salary FROM employees) WHERE department_id = 90;
  • C.
    UPDATE old_employees a FROM employees b SET a.salary = b.salary WHERE department_id = 90;
  • D.
    UPDATE old_employees a SET salary = (SELECT salary FROM employees b WHERE a.employee_id = b.employee_id AND department_id = 90);
  • Answer & Explanation
  • Report
Answer : [A]
Explanation :
Option A uses a correlated subquery to match the correct employee. Option B selects all the rows in the subquery and, therefore, will generate an error. Option C is not valid syntax. Option D will update all the rows in the table because the UPDATE statement does not have a WHERE clause. The WHERE clause preset belongs to the subquery.
Report
Name Email  
44.
Review the following code snippet. Which line has an error?
1. UPDATE EMPLOYEES
2. WHERE EMPLOYEE_ID = 127
3. SET SALARY = SALARY * 1.25,
4. COMMISSION_PCT = 0
  • A.
    1
  • B.
    2
  • C.
    4
  • D.
    There is no Error
  • Answer & Explanation
  • Report
Answer : [B]
Explanation :
In an UPDATE statement, the WHERE clause should come after the SET clause.
Report
Name Email  
45.
Jim executes the following SQL statement. What will be the result?
DELETE salary, commission_pct
FROM employees
WHERE department_id = 30;
  • A.
    The salary and commission_pct columns for all records with department_id 30 will be deleted (changed to NULL).
  • B.
    All the rows belonging to department_id 30 will be deleted from the table.
  • C.
    The salary and commission_pct columns will be deleted from the employees table.
  • D.
    The statement will produce an error.
  • Answer & Explanation
  • Report
Answer : [D]
Explanation :
When deleting a row from a table, do not use column names. To change column values to NULL, use the UPDATE statement.
Report
Name Email