SQL CRUD Operations Mastery Quiz Quiz

  1. Basic SELECT Query

    Which SQL statement correctly retrieves all columns from the 'users' table?

    1. SELECT * FROM users;
    2. GET ALL FROM users;
    3. SELECT ALL users;
    4. PICK * FROM users;
    5. SELLECT * FROM users;
  2. Inserting New Data

    What is the correct SQL statement to add a new row with name 'John' and age 25 into the 'people' table (columns: name, age)?

    1. INSERT INTO people (name, age) VALUES ('John', 25);
    2. ADD (name='John', age=25) TO people;
    3. INSERT people name='John', age=25;
    4. INSERT INTO people VALUES ('John', 25);
    5. INSET INTO people (name, age) VALUES ('John', 25);
  3. Updating Existing Records

    Choose the proper SQL command to set the 'status' column to 'active' for a row in the 'accounts' table where id is 7.

    1. UPDATE accounts SET status = 'active' WHERE id = 7;
    2. CHANGE accounts SET status = 'active' WITH id = 7;
    3. MODIFY accounts status = 'active' WHERE id = 7;
    4. UPDATE accounts status = 'active' WHEN id = 7;
    5. UPDTAE accounts SET status = 'active' WHERE id = 7;
  4. Deleting Records Safely

    Which SQL statement correctly deletes the row from the 'orders' table where order_id is 102?

    1. DELETE FROM orders WHERE order_id = 102;
    2. REMOVE FROM orders WHERE order_id = 102;
    3. DELETE orders WHERE order_id = 102;
    4. DEL FROM orders WHERE order_id = 102;
    5. DELETE * FROM orders WHERE order_id = 102;
  5. Replacing Existing Items

    What happens if you use INSERT INTO on a table and supply a primary key value that already exists?

    1. The existing row is replaced with the new row data.
    2. An error occurs; duplicate primary keys are not allowed.
    3. The new row is appended with a warning.
    4. No action is taken; existing row remains.
    5. The table is truncated before insert.
  6. Batch Writing in SQL

    Which set of SQL operations can typically be executed in a single batch write statement to multiple tables?

    1. INSERT and DELETE
    2. UPDATE and INSERT
    3. DELETE and UPDATE
    4. READ and WRITE
    5. ALTER and SELECT
  7. Understanding Conditional Updates

    What does a conditional UPDATE statement do in SQL?

    1. Performs the update only if certain conditions about the data are met.
    2. Updates all records without checking any condition.
    3. Deletes the record if the condition fails.
    4. Creates a new record if the condition is true.
    5. Ignores records that match the condition.
  8. Querying by Composite Key

    If a table uses a composite primary key (user_id, date), what must you provide to update a single row?

    1. Both user_id and date values
    2. Only the user_id value
    3. Any one of the primary key columns
    4. None of the key values
    5. Just the table name
  9. Atomic Counters

    What does an atomic counter operation do in an UPDATE statement in SQL?

    1. Increments or decrements a numeric column in a row atomically
    2. Deletes a numeric column if it is zero
    3. Resets the counter to the initial value
    4. Splits the row into two rows
    5. Ignores all numeric changes
  10. Efficient Updating vs. Delete-Insert

    For changing a single column value in a large table, which operation is generally more efficient?

    1. UPDATE command on the row
    2. DELETE the row and then INSERT it with new value
    3. Drop the table and create a new one
    4. CREATE a duplicate table and copy data
    5. Run SELECT followed by REPLACE