Safe Updates
Which SQL statement is used to modify existing data in a table?
- SELECT
- UPDATE
- INSERT
- DELETE
- MODIFY
Preventing Bulk Changes
What part of an UPDATE statement is crucial for preventing accidental changes to all rows in a table?
- The SET clause
- The FROM clause
- The WHERE clause
- The ORDER BY clause
- The GROUP BY clause
Safe INSERT statements
What SQL command is used to add new records to a table?
- ADD
- CREATE
- INSERT
- UPDATE
- NEW
Safe DELETE statements
What SQL command is used to remove records from a table?
- REMOVE
- DELETE
- ERASE
- DROP
- TRUNCATE
Handling NULL Values
Consider an UPDATE statement with a WHERE clause checking a status field; what special consideration should be given to NULL values in that field?
- They should be ignored.
- They should be treated as zero.
- The WHERE clause should explicitly handle NULL values.
- NULL values are automatically handled.
- NULL values will cause an error.
Importance of Transactions
When performing data modifications, what mechanism allows you to undo the changes if an error occurs?
- A backup
- A rollback
- An audit log
- A data dictionary
- A commit
Testing Updates
Before running an UPDATE statement on a production database, what is a good practice to verify its effect?
- Running the update without a WHERE clause
- Running a SELECT statement with the same WHERE clause
- Running the update on a different table
- Commenting out the update statement
- Running the statement in a production environment
Selecting Query Text
When executing SQL queries, especially those modifying data, what practice can help ensure the entire query is run, especially in interfaces where the full query is not visible?
- Drag the cursor from the top to the bottom of the query.
- Drag the cursor from the bottom to the top of the query.
- Double-click the query.
- Use a keyboard shortcut.
- It doesn't matter, just copy and paste.
Code Review Importance
Why is it beneficial to have another person review data modification queries before they are executed in a production environment?
- To ensure the code is properly formatted
- To catch potential errors and prevent mistakes
- To speed up the execution process
- To ensure only one person knows the query
- To reduce server load
Recovery from Errors
What is the most important first step to take if you realize you have made a data-altering mistake in a production database?
- Attempt to fix it without telling anyone.
- Immediately inform your team lead or supervisor.
- Run a full backup of the database.
- Document the mistake in a private log.
- Reboot the server.