SQL Multiple Choice Quiz (Beginner Level) total-qa June 13, 2025 June 13, 2025 No Comments on SQL Multiple Choice Quiz (Beginner Level) 1. What is SQL? Structured Query Language Structured Question Language Sequential Query Language Stored Query Language SQL stands for Structured Query Language. It is a standardized programming language used for managing and manipulating relational databases. SQL is used to perform tasks such as: Retrieving data (SELECT) Inserting data (INSERT) Updating data (UPDATE) Deleting data (DELETE) Creating or modifying database structures (CREATE, ALTER) 2. Which SQL statement is used to retrieve data from a database? GET SELECT RETRIEVE SHOW Explanation: The SELECT statement is used to retrieve data from one or more tables in a database. 3. Which clause is used to filter the records in a SQL query? ORDER BY GROUP BY HAVING WHERE Explanation: The WHERE clause filters rows before grouping or displaying them, based on specified conditions. 4. What does the COUNT(*) function do in SQL? Counts only NULL values Counts the number of tables Counts all rows in a table Counts distinct rows only Explanation: COUNT(*) counts all rows, including those with NULL values. 5. Which SQL keyword is used to sort the result set? ORDER SORT BY GROUP ORDER BY Explanation: ORDER BY is used to sort the result set in ascending or descending order. 6. What is the purpose of the GROUP BY clause? Filter rows Combine rows with the same values Remove duplicates Create indexes Explanation: GROUP BY groups rows that have the same values in specified columns, often used with aggregate functions like SUM, AVG, or COUNT. 7. Which command is used to remove all records from a table but not the table itself? DELETE DROP TRUNCATE REMOVE Explanation: TRUNCATE removes all rows from a table efficiently but keeps the table structure intact. 8. What does PRIMARY KEY ensure in a table? The column is always NULL Uniqueness and NOT NULL Foreign relationship It is indexed only Explanation: A PRIMARY KEY uniquely identifies each record and does not allow NULLs. 9. What is the default sort order of ORDER BY in SQL? DESC ASC RANDOM NONE Explanation: If no order is specified, ORDER BY defaults to ascending (ASC), meaning lowest to highest or A to Z. 10. Which operator is used to search for a specified pattern in a column? FIND MATCH LIKE SEARCH Explanation: The LIKE operator is used with wildcards (%, _) to find patterns in text fields. 11. What is a JOIN in SQL? A way to delete multiple tables A command to create tables A method to combine rows from two or more tables A way to rename columns Explanation: A JOIN retrieves data from multiple tables based on related columns, such as a foreign key. 12. Which of the following is used to remove duplicate records in SQL? DELETE UNIQUE DISTINCT EXCEPT Explanation: The DISTINCT keyword filters out duplicate rows in a SELECT query, returning only unique results. 13. Which of these is not a valid SQL data type? VARCHAR INT TEXT WORD Explanation: WORD is not a valid SQL data type. Common types include VARCHAR, INT, TEXT, etc. 14. Which of these statements creates a new table? ADD TABLE MAKE TABLE CREATE TABLE INSERT TABLE Explanation: CREATE TABLE defines a new table structure in the database. 15. What is the purpose of a FOREIGN KEY? Uniquely identify a row in the same table Connect two unrelated databases Create a copy of another table Establish a relationship between two tables Explanation: A FOREIGN KEY ensures referential integrity by linking a column in one table to the PRIMARY KEY in another. 16. Which command adds a new row to a table? ADD UPDATE INSERT INTO APPEND Explanation: INSERT INTO is used to add new records (rows) into a table. 17. Which of the following allows duplicate values in a table? PRIMARY KEY UNIQUE KEY FOREIGN KEY All of the above Explanation: A FOREIGN KEY can contain duplicate values because it’s used to establish a relationship, not ensure uniqueness. 18. What is the main purpose of a PRIMARY KEY in a table? To allow NULL values To sort data by default To uniquely identify each record To reference another table Explanation: A PRIMARY KEY ensures that each row in a table is unique and cannot be NULL. 19. Which statement is true about a composite primary key? It can include NULL values It uses multiple columns to uniquely identify a row It must be used in every table It is the same as a foreign key Explanation: A composite primary key is made up of two or more columns that, together, ensure row uniqueness. 20. What does the IS NULL condition check for? Zero values Blank spaces NULL or missing values Empty strings Explanation: IS NULL checks whether a column value is NULL, which means no value has been assigned. Loading …