Oracle Database Sql Certified Associate · Free Practice Question Medium

Question 37

Table: PRODUCTS


Given:

  • Rows exist in this table with data in all the columns.

  • The PRODUCTS table in read-only mode. 

Identify the command which execute successfully on PRODUCTS.

  • A

    ALTER TABLE products DROP COLUMN expiry_date;

  • B

    ALTER TABLE products DROP UNUSED COLUMNS;

  • C

    ALTER TABLE products SET UNUSED (expiry_date);

  • D

    TRUNCATE TABLE products;

  • E

    CREATE INDEX price_idx ON products (price);

Reveal correct answer

Correct answer: E

Explanation

The table in read-only is different from DB in read-only.

Since the PRODUCTS table is in read-only mode, you cannot perform any DML (Data Manipulation Language) or DDL (Data Definition Language) operations that modify the table's structure or data.

Analyzing the given commands:

  1. CREATE INDEX price_idx ON products (price);
    This will execute successfully.

    • Creating an index does not modify table data, so it is allowed in read-only mode.

  2. ALTER TABLE products DROP UNUSED COLUMNS;
    This will fail.

    • Dropping unused columns modifies the table structure, which is not allowed in read-only mode.

  3. ALTER TABLE products SET UNUSED (expiry_date);
    This will fail.

    • Marking a column as unused modifies the table structure.

  4. ALTER TABLE products DROP COLUMN expiry_date;
    This will fail.

    • Dropping a column changes the schema, which is not allowed.

  5. TRUNCATE TABLE products;
    This will fail.

    • TRUNCATE removes all rows, which modifies the data.

When a table is in read-only mode, operations that attempt to modify table data are disallowed. The following operations are not permitted on a read-only table:

All DML operations on the table or any of its partitions

A.

Fails: Dropping a column modifies the table structure, which is prohibited in read-only mode.

B.

Fails: This modifies the table structure by dropping unused columns, which is not allowed in read-only mode.

C.

Fails: Marking a column as unused alters the table structure, which is not allowed in read-only mode.

D.

Fails: Truncating a table removes all rows, which changes the data, and this is not allowed in read-only mode.

E.

Succeeds: Creating an index does not modify the table's data or structure, so this command is allowed.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need