HOME
Welcome to the SQL Quiz! This blog post features 25 multiple-choice questions that explore essential concepts of SQL.
1. What is a database?
Select the best answer
a) Organized collection of information that cannot be accessed, updated, and managed
b) Collection of data or information without organizing
c) Organized collection of data or information that can be accessed, updated, and managed
d) Organized collection of data that cannot be updated
Answer
2. In which of the following formats data is stored in the database management system?
Choose one option
a) Image
b) Text
c) Table
d) Graph
Answer
3. What needs correction in
SELECT * FROM Employees WHERE Salary = 5000 AND Department = 'HR';"
Choose one option
a) All Correct
b) = in Salary
c) AND
d) = in Department
Answer
4. Identify the error in
UPDATE Employees SET Salary = Salary * 1.05 WHERE;
Choose one option
a) UPDATE keyword
b) SET keyword
c) WHERE clause
d) No error
Answer
5. The OR operator displays a record if ANY conditions listed are true. The AND operator displays a record if ALL of the conditions listed are true
a) True
b) False
Answer
6. With SQL, how do you select all the records from a table named “Employees” where the “FirstName” is “Peter” and the “LastName” is “Jackson”?
Choose one option
a) SELECT * FROM Employees WHERE FirstName='Peter' AND LastName='Jackson'
b) SELECT FirstName='Peter', LastName='Jackson' FROM Employees
c) SELECT * FROM Employees WHERE FirstName<>'Peter' AND LastName<>'Jackson'
d) SELECT * FROM Employees WHERE FirstName='Jackson' AND LastName='Peter'
Answer
7. What is missing in the following statement?
INSERT INTO Employees (Name, Department) VALUES ('John', 'Sales');
a) All Correct
b) Employee ID
c) a) WHERE clause
d) Additional column names
Answer
8. Identify the error in
SELECT * FROM Orders WHERE OrderDate >= '2023-01-01' OR >= '2023-06-01';
Choose one option
a) OR operator
b) >= ‘2023-06-01’
c) No error
d) The date format
Answer
9. Correct the syntax error in
DELETE FROM Employees HAVING Age < 25;
Choose one option
a) DELETE keyword
b) FROM keyword
c) HAVING keyword
d) No syntax error
Answer
10. Identify the error
UPDATE Employees SET Age = Age + 1 WHERE Department IN ('Sales', 'HR') AND Age >= 30;
Choose one option
a) The IN operator
b) The AND operator
c) No error
d) The SET keyword
Answer
11. With SQL, how do you select all the records from a table named “Employees” where the “LastName” is alphabetically between (and including) “Hansen” and “Pettersen”?
Choose one option
a) SELECT * FROM Employees WHERE LastName BETWEEN 'Hansen' AND 'Pettersen'
b) SELECT * FROM Employees WHERE LastName>'Hansen' AND LastName<'Pettersen'
c) SELECT LastName>'Hansen' AND LastName<'Pettersen' FROM Employees
d) None
Answer
12. Which SQL statement is used to return only different values?
Choose one option
a) SELECT DISTINCT
b) SELECT DIFFERENT
c) SELECT UNIQUE
d) SELECT TOP
Answer
13. Which SQL keyword is used to sort the result-set?
Choose one option
a) ORDER BY
b) ORDER
c) SORT
d) SORT BY
Answer
14. With SQL, how can you return all the records from a) table named “Employees” sorted descending by “FirstName”?
Choose one option
a) SELECT * FROM Employees ORDER BY FirstName DESC
b) SELECT * FROM Employees SORT 'FirstName' DESC
c) SELECT * FROM Employees SORT BY 'FirstName' DESC
d) SELECT * FROM Employees ORDER FirstName DESC
Answer
15. With SQL, how can you insert a new record into the “Employees” table?
Choose one option
a) INSERT INTO Employees VALUES ('Jimmy', 'Jackson')
b) INSERT VALUES ('Jimmy', 'Jackson') INTO Employees
c) INSERT ('Jimmy', 'Jackson') INTO Employees
d) INSERT INTO Table Employees VALUES ('Jimmy', 'Jackson')
Answer
16. With SQL, how can you insert “Olsen” as the “LastName” in the “Persons” table?
Choose one option
a) INSERT INTO Persons (LastName) VALUES ('Olsen')
b) INSERT ('Olsen') INTO Persons (LastName)
c) INSERT INTO Persons ('Olsen') INTO LastName
d) All incorrect
Answer
17. What is the primary purpose of the GRANT command in SQL?
Choose one option
a) To create a new table
b) To delete data from a table
c) To give users access privileges
d) To update table data
Answer
18. What does the REVOKE command do in SQL?
Choose one option
a) Adds new user accounts
b) Removes specific access privileges from users
c) Deletes tables
d) Inserts data
Answer
19. Which part of this statement is incorrect?
GRANT SELECT ON Employees TO user123;
Choose one option
a) GRANT
b) SELECT ON
c) Employees
d) All Correct
Answer
20. Which part of this statement is incorrect?
REVOKE INSERT, UPDATE ON Database FROM user123;
Choose one option
a) REVOKE
b) INSERT, UPDATE
c) ON Database
d) FROM user123
Answer
21. How can you change “Hansen” into “Nilsen” in the “LastName” column in the Employees table?
Choose one option
a) UPDATE Employees SET LastName='Nilsen' WHERE LastName='Hansen'
b) MODIFY Employees SET LastName='Nilsen' WHERE LastName='Hansen'
c) UPDATE Employees SET LastName='Hansen' INTO LastName='Nilsen'
d) MODIFY Employees SET LastName='Hansen' INTO LastName='Nilsen
Answer
22. With SQL, how can you delete the records where the “FirstName” is “Peter” in the Employees Table?
Choose one option
a) DELETE FROM Employees WHERE FirstName = 'Peter'
b) DELETE FirstName='Peter' FROM Employees
c) DELETE ROW FirstName='Peter' FROM Employees
d) All are incorrect
Answer
23. With SQL, how can you return the number of records in the “Employees” table?
Choose one option
a) SELECT COUNT(*) FROM Employees
b) SELECT COLUMNS(*) FROM Employees
c) SELECT LEN(*) FROM Employees
d) SELECT NO(*) FROM Employees
Answer
24. What is the most common type of join?
Choose one option
a) JOINED
b) JOINED TABLE
c) INSIDE JOIN
d) INNER JOIN
Answer
25. Which operator is used to select values within a range?
Choose one option
a) BETWEEN
b) WITHIN
c) RANGE
Answer
====================================================================