Which of the following best explains why CRUD operations are fundamental in database management?
Think about the basic actions you need to manage any data in a database.
CRUD stands for Create, Read, Update, and Delete. These operations cover all basic ways to manage data in a database, making them fundamental.
Given the table users with columns id and name, what is the output of this query?
SELECT name FROM users WHERE id = 2;
CREATE TABLE users (id INT, name TEXT); INSERT INTO users VALUES (1, 'Alice'), (2, 'Bob'), (3, 'Charlie'); SELECT name FROM users WHERE id = 2;
Look for the row where id equals 2 and select the name column.
The query selects the name from the users table where id is 2, which is 'Bob'.
Which option shows the correct SQL syntax to update the email of a user with id 5 in the customers table?
Think about the standard SQL command used to change existing data.
The correct command to update data in SQL is UPDATE. The other commands are invalid for this purpose.
Which approach is best to efficiently delete many rows from a large table without locking the entire table?
Think about how to avoid long locks and heavy load on the database.
Deleting in small batches reduces locking and resource usage, making the operation smoother on large tables.
Consider this SQL statement:
INSERT INTO orders (order_id, customer_id, order_date) VALUES (101, NULL, '2024-01-01');
The customer_id column is defined as INTEGER NOT NULL. What error will this cause?
Think about what NOT NULL means for a column and what happens if you insert NULL.
The NOT NULL constraint means the column cannot have NULL values. Trying to insert NULL causes a constraint violation error.