Understanding CRUD Basics
Which of the following operations is NOT represented by the CRUD acronym in the context of databases?
- Create
- Read
- Upload
- Update
- Delete
SQL Statement for Deleting Data
What is the correct SQL statement to remove all records from a table named 'users'?
- DELETE FROM users;
- REMOVE ALL FROM users;
- DROP users;
- DELETE * FROM users;
- ERASE users;
Primary Key Constraint
In a relational database, what is the main purpose of a primary key in a table?
- To uniquely identify each row
- To store encrypted passwords
- To speed up database backups
- To allow multiple rows with the same value
- To prevent data from being read
Choosing the Correct SQL SELECT Syntax
Which SQL query selects all columns from the 'products' table?
- SELECT * FROM products;
- CHOOSE ALL FROM products;
- SELECT products FROM *;
- FIND FROM products;
- SELECT ALL FROM products
Updating Records Scenario
To change the email address of a user with id=7 in the 'users' table, which SQL statement should you use?
- UPDATE users SET email = 'new@email.com' WHERE id = 7;
- MODIFY users email TO 'new@email.com' IF id = 7;
- CHANGE users email = 'new@email.com' ON id = 7;
- ALTER users SET email='new@email.com' AND id=7;
- UPDATE users email = 'new@email.com' WHERE id IS 7;
Preventing Duplicate Data
Which database constraint prevents duplicate values in a specific column?
- UNIQUE
- PRIMARY
- INDEX
- FOREIGN
- REFERENCE
Inserting Data Correctly
What is the correct way to insert a new record into a table called 'orders' with columns 'id' and 'amount' in SQL?
- INSERT INTO orders (id, amount) VALUES (1, 100);
- ADD INTO orders VALUES (1, 100);
- INSERT orders (id, amount) = (1, 100);
- PUT (1, 100) IN orders;
- INSERT TO orders VALUES (1, 100);
Retrieving Unique Values
Which SQL keyword will return only distinct (different) values from the 'category' column of a 'items' table?
- SELECT DISTINCT category FROM items;
- SELECT UNIQUE category IN items;
- SELECT category ONLY FROM items;
- SELECT DIFFERENT category FROM items;
- SELECT category FROM items UNIQUE;
Nested SELECT Usage
What is the role of a subquery in a SQL statement?
- It returns data for use by the main query
- It updates all rows in a table
- It creates a new table in the database
- It drops columns from a table
- It sorts the results by ascending order
Effect of SQL DROP Operation
What does the SQL command DROP TABLE users; do?
- Deletes the entire 'users' table and all its data
- Removes only the data from 'users', keeps the table structure
- Deletes one row from the 'users' table
- Deletes the primary key from the 'users' table
- Removes only null values from the 'users' table