Tag: databases

Questions Related to databases

  1. MERGE INTO new_employees c USING employees e ON (c.employee_id = e.employee_id) WHEN MATCHED THEN UPDATE SET c.name = e.first_name ||','|| e.last_name WHEN NOT MATCHED THEN INSERT VALUES(e.employee_id, e.first_name ||', '||e.last_name);

  2. MERGE new_employees c USING employees e ON (c.employee_id = e.employee_id) WHEN EXISTS THEN UPDATE SET c.name = e.first_name ||','|| e.last_name WHEN NOT MATCHED THEN INSERT VALUES(e.employee_id, e.first_name ||', '||e.last_name);

  3. MERGE INTO new employees c USING employees e ON (c.employee_id = e.employee_id) WHEN EXISTS THEN UPDATE SET c.name = e.first_name ||','|| e.last_name WHEN NOT MATCHES THEN INSERT VALUES(e.employee_id, e.first_name ||', '||e.last_name);

  4. MERGE new_employees c FROM employees e ON (c.employee_id = e.employee_id) WHEN MATCHED THEN UPDATE SET c.name = e.first_name ||','|| e.last_name WHEN NOT MATCHED THEN INSERT INTO new_employees VALUES(e.employee_id, e.first_name ||'.'||e.last_name);


Correct Option: A
Explanation:

To determine which MERGE statement is valid, we need to examine the syntax of each option and compare it to the requirements of the question.

The question provides two tables: EMPLOYEES and NEW EMPLOYEES. Both tables have an EMPLOYEE_ID column as the primary key. The goal of the MERGE statement is to update the NAME column in the NEW EMPLOYEES table with the concatenated FIRST_NAME and LAST_NAME values from the EMPLOYEES table. If an employee exists in the NEW EMPLOYEES table, the NAME should be updated. If the employee does not exist, a new row should be inserted.

Now let's examine each option:

A. MERGE INTO new_employees c USING employees e ON (c.employee_id = e.employee_id) WHEN MATCHED THEN UPDATE SET c.name = e.first_name ||','|| e.last_name WHEN NOT MATCHED THEN INSERT VALUES(e.employee_id, e.first_name ||', '||e.last_name);

This option is valid. It uses the correct syntax for a MERGE statement and joins the two tables on the EMPLOYEE_ID column. It updates the NAME column in the NEW EMPLOYEES table with the concatenated FIRST_NAME and LAST_NAME values from the EMPLOYEES table. If a match is not found, a new row is inserted into the NEW EMPLOYEES table.

B. MERGE new_employees c USING employees e ON (c.employee_id = e.employee_id) WHEN EXISTS THEN UPDATE SET c.name = e.first_name ||','|| e.last_name WHEN NOT MATCHED THEN INSERT VALUES(e.employee_id, e.first_name ||', '||e.last_name);

This option is invalid. It uses the correct syntax for a MERGE statement, but the WHEN EXISTS clause is not valid. It should be WHEN MATCHED instead. Additionally, the syntax for the UPDATE clause is incorrect.

C. MERGE INTO new employees c USING employees e ON (c.employee_id = e.employee_id) WHEN EXISTS THEN UPDATE SET c.name = e.first_name ||','|| e.last_name WHEN NOT MATCHES THEN INSERT VALUES(e.employee_id, e.first_name ||', '||e.last_name);

This option is invalid. It has a syntax error in the WHEN NOT MATCHES clause, which should be WHEN NOT MATCHED. Additionally, the UPDATE clause syntax is incorrect.

D. MERGE new_employees c FROM employees e ON (c.employee_id = e.employee_id) WHEN MATCHED THEN UPDATE SET c.name = e.first_name ||','|| e.last_name WHEN NOT MATCHED THEN INSERT INTO new_employees VALUES(e.employee_id, e.first_name ||'.'||e.last_name);

This option is invalid. It does not use the correct syntax for a MERGE statement. Additionally, the INSERT INTO clause syntax is incorrect.

Thus, the valid MERGE statement is:

The Answer is: A. MERGE INTO new_employees c USING employees e ON (c.employee_id = e.employee_id) WHEN MATCHED THEN UPDATE SET c.name = e.first_name ||','|| e.last_name WHEN NOT MATCHED THEN INSERT VALUES(e.employee_id, e.first_name ||', '||e.last_name);

  1. a. The database stores the same column for a group of rows together

  2. b. The data block does not store the rows in the row-major format

  3. c. The database stores the identical rows together with a reference for each row

  4. d. Database operations works transparently against compressed objects without the need of changing application code


Correct Option: A,B,D
  1. a. Warehouse Compression & Online Archival Compression

  2. b. Basic Compression, Warehouse Compression & Online Archival Compression

  3. c. Basic Compression, OLTP Compression, Warehouse Compression & Online Archival Compression

  4. d. OLTP Compression, Warehouse Compression & Online Archival Compression


Correct Option: A
  1. a. Compression unit can span across multiple data blocks

  2. b. The value of particular column can span across multiple blocks

  3. c. If a column in a compression unit is updated, the database will take a lock only on the updated rows

  4. d. If a column in a compression unit is updated, the database will take a lock on the entire compression unit


Correct Option: A,B,D

When tables use Exadata Hybrid Columnar Compression, Oracle DML locks larger blocks of data (compression unit) which might reduce concurrency

  1. a. For basic and online archival compression inserted and updated rows are uncompressed

  2. b. Higher compression levels of Exadata Hybrid Columnar Compression are achieved only with data that is direct-path inserted

  3. c. High CPU overhead in case Warehouse compression

  4. d. Conventional inserts and updates are supported in Exadata Hybrid Columnar Compression but the extent of compression is low


Correct Option: A,B,C,D
  1. a. COMPRESS FOR QUERY HIGH should be used where load performance is critical

  2. b. COMPRESS FOR QUERY LOW should be used where load performance is critical

  3. c. COMPRESS FOR ARCHIVE HIGH should be used for rarely accessed application

  4. d. COMPRESS FOR ARCHIVE HIGH should be used for heavily accessed application


Correct Option: B,C

CELL_OFFLOAD_PROCESSING parameter effect can be also achieved by OPT_PARAM hint

  1. True

  2. False


Correct Option: A
  1. CELL_OFFLOAD_PROCESSING parameter can be used to compare the performance of Exadata Cell with conventional storage
  1. True

  2. False


Correct Option: B