SQL Queries & Commands MCQs with Answers
Which SQL keyword is used to retrieve data from a database?
a) GET
b) SELECT
c) FETCH
d) RETRIEVE
What is the purpose of the WHERE clause in an SQL query?
a) To specify the table to query
b) To filter records based on a condition
c) To group records
d) To order the results
Which SQL statement is used to insert new records into a table?
a) ADD
b) INSERT INTO
c) CREATE TABLE
d) INSERT RECORD
Which SQL keyword is used to modify existing data in a table?
a) MODIFY
b) UPDATE
c) ALTER
d) CHANGE
What is the correct SQL syntax for deleting a record from a table?
a) REMOVE FROM table_name WHERE condition
b) DELETE FROM table_name WHERE condition
c) DELETE table_name WHERE condition
d) DROP FROM table_name WHERE condition
Which SQL statement is used to remove a table from a database?
a) DELETE TABLE
b) REMOVE TABLE
c) DROP TABLE
d) DELETE FROM TABLE
What does the SQL GROUP BY clause do?
a) Groups rows that have the same values into summary rows
b) Sorts the result set
c) Combines multiple tables into one result
d) Filters the results of a query
Which SQL function is used to count the number of rows in a table?
a) COUNT()
b) SUM()
c) AVERAGE()
d) TOTAL()
Which SQL clause is used to filter records based on aggregate functions like COUNT, AVG, etc.?
a) GROUP BY
b) ORDER BY
c) HAVING
d) WHERE
What is the default sorting order in SQL when using the ORDER BY clause?
a) Random
b) Descending
c) Ascending
d) Unsorted
What does the SQL DISTINCT keyword do?
a) Removes duplicate rows from the result set
b) Sorts the result set in descending order
c) Limits the number of rows returned
d) Updates the values in the table
Which SQL function is used to find the highest value in a column?
a) MAX()
b) MIN()
c) AVG()
d) SUM()
Which SQL command is used to change a column’s datatype in a table?
a) MODIFY COLUMN
b) ALTER COLUMN
c) UPDATE COLUMN
d) CHANGE COLUMN
Which SQL operator is used to combine the results of two SELECT statements?
a) JOIN
b) UNION
c) MERGE
d) INTERSECT
Which SQL clause is used to filter records before GROUP BY is applied?
a) HAVING
b) WHERE
c) ORDER BY
d) SELECT
What does the SQL LIKE operator do?
a) Compares two values for equality
b) Performs pattern matching in a column
c) Finds exact matches in a column
d) Deletes records based on a condition
What is the SQL syntax to create a new table in a database?
a) CREATE DATABASE table_name
b) CREATE TABLE table_name
c) MAKE TABLE table_name
d) NEW TABLE table_name
Which of the following is used to join two tables based on a related column?
a) UNION
b) JOIN
c) INTERSECT
d) GROUP BY
What is the SQL command to add a new column to an existing table?
a) ADD COLUMN
b) MODIFY TABLE
c) ALTER TABLE
d) CHANGE COLUMN
Which SQL clause is used to sort the result set by one or more columns?
a) SORT BY
b) ORDER BY
c) GROUP BY
d) FILTER BY
What is the SQL syntax to find records with a NULL value in a column?
a) SELECT * FROM table_name WHERE column IS EMPTY
b) SELECT * FROM table_name WHERE column IS NULL
c) SELECT * FROM table_name WHERE column = NULL
d) SELECT * FROM table_name WHERE column IS NOT NULL
Which of the following statements is used to update existing records in a table?
a) MODIFY
b) ALTER
c) UPDATE
d) CHANGE
What SQL keyword is used to limit the number of rows returned by a query?
a) LIMIT
b) TOP
c) RANK
d) RESTRICT
Which of the following is true about the SQL INNER JOIN?
a) It returns all rows from both tables, even if they do not match
b) It returns only rows with matching values in both tables
c) It returns all rows from the first table
d) It returns all rows from the second table
Which of the following operators is used to compare a value against a list of values in SQL?
a) BETWEEN
b) IN
c) LIKE
d) EXISTS
Which of the following SQL commands is used to modify the structure of an existing table?
a) CREATE TABLE
b) MODIFY TABLE
c) ALTER TABLE
d) DROP TABLE
What does the SQL keyword DISTINCT do?
a) Returns only unique values
b) Removes all null values
c) Sorts data in ascending order
d) Combines two or more queries
What is the correct SQL syntax to find the number of rows in a table?
a) SELECT COUNT() FROM table_name
b) SELECT SUM() FROM table_name
c) SELECT NUMROWS FROM table_name
d) SELECT ROWCOUNT FROM table_name
Which of the following SQL clauses is used to group rows that have the same values into summary rows?
a) WHERE
b) ORDER BY
c) GROUP BY
d) HAVING
What is the correct SQL syntax to update a record in a table?
a) UPDATE table_name SET column_name = value WHERE condition
b) MODIFY table_name SET column_name = value WHERE condition
c) CHANGE table_name SET column_name = value WHERE condition
d) ALTER table_name SET column_name = value WHERE condition
Which SQL command is used to remove data from a table without deleting the table itself?
a) REMOVE
b) DELETE
c) TRUNCATE
d) DROP