SQL MCQs for all Upcoming Examinations

Here are 50 SQL MCQs with answers:


1. What does SQL stand for?

  • A) Simple Query Language
  • B) Structured Query Language
  • C) Standard Query Language
  • D) System Query Language

Answer: B) Structured Query Language
SQL is the standard language used for managing and manipulating relational databases.


2. Which of the following is the correct syntax to retrieve all records from the “Customers” table?

  • A) SELECT * FROM Customers;
  • B) GET ALL FROM Customers;
  • C) SELECT ALL * FROM Customers;
  • D) SELECT * FROM Customer;

Answer: A) SELECT * FROM Customers;
The correct syntax to retrieve all records from a table is SELECT * FROM table_name;.


3. Which SQL statement is used to delete data from a table?

  • A) REMOVE
  • B) DELETE
  • C) DROP
  • D) CLEAR

Answer: B) DELETE
The DELETE statement is used to remove records from a table.


4. Which SQL clause is used to filter records?

  • A) WHERE
  • B) HAVING
  • C) LIMIT
  • D) GROUP BY

Answer: A) WHERE
The WHERE clause is used to filter records based on specific conditions.


5. What is the correct SQL syntax for updating data in a database?

  • A) UPDATE table_name SET column1 = value1 WHERE condition;
  • B) UPDATE table_name SET column1 = value1;
  • C) MODIFY table_name SET column1 = value1 WHERE condition;
  • D) CHANGE table_name SET column1 = value1 WHERE condition;

Answer: A) UPDATE table_name SET column1 = value1 WHERE condition;
The UPDATE statement modifies existing records based on a specified condition.


6. Which SQL function is used to find the highest value in a column?

  • A) MAX()
  • B) MIN()
  • C) TOP()
  • D) HIGH()

Answer: A) MAX()
The MAX() function returns the largest value in a specified column.


7. What does the SQL JOIN clause do?

  • A) Combines rows from two or more tables
  • B) Deletes data from multiple tables
  • C) Creates a new table
  • D) Filters data from one table

Answer: A) Combines rows from two or more tables
JOIN is used to combine data from multiple tables based on a related column.


8. Which SQL keyword is used to prevent duplicate records?

  • A) UNIQUE
  • B) DISTINCT
  • C) NO_DUPLICATES
  • D) DISTINCTROW

Answer: B) DISTINCT
The DISTINCT keyword is used to remove duplicate records from the result set.


9. Which SQL statement is used to create a new table?

  • A) CREATE NEW TABLE
  • B) CREATE TABLE
  • C) ADD TABLE
  • D) MAKE TABLE

Answer: B) CREATE TABLE
The CREATE TABLE statement is used to create a new table in a database.


10. Which of the following SQL statements is used to retrieve unique values from a column?

  • A) SELECT DISTINCT column_name FROM table_name;
  • B) SELECT column_name FROM table_name;
  • C) SELECT UNIQUE column_name FROM table_name;
  • D) SELECT ALL column_name FROM table_name;

Answer: A) SELECT DISTINCT column_name FROM table_name;
The DISTINCT keyword is used to select unique values from a specified column.


11. In SQL, what does the INNER JOIN do?

  • A) Returns rows with matching values in both tables
  • B) Returns all rows from the left table, even if there are no matches in the right table
  • C) Returns all rows from the right table
  • D) Returns unmatched rows from both tables

Answer: A) Returns rows with matching values in both tables
INNER JOIN returns only the rows where there is a match in both tables.


12. Which SQL clause is used to group rows that have the same values into summary rows?

  • A) GROUP BY
  • B) HAVING
  • C) ORDER BY
  • D) JOIN

Answer: A) GROUP BY
The GROUP BY clause is used to group rows based on column values and perform aggregate functions on those groups.


13. What does the LIMIT clause do in SQL?

  • A) Limits the number of columns in the result
  • B) Limits the number of rows returned in the result
  • C) Limits the size of the database
  • D) Limits the number of tables in the query

Answer: B) Limits the number of rows returned in the result
The LIMIT clause restricts the number of rows returned by the query.


14. What is the purpose of the SQL ORDER BY clause?

  • A) To filter rows
  • B) To sort rows in ascending or descending order
  • C) To join tables
  • D) To update records

Answer: B) To sort rows in ascending or descending order
The ORDER BY clause is used to sort the result set by one or more columns in ascending or descending order.


15. What does the SQL COUNT() function do?

  • A) Returns the number of rows in a table
  • B) Returns the sum of values in a column
  • C) Returns the average of values in a column
  • D) Returns the highest value in a column

Answer: A) Returns the number of rows in a table
The COUNT() function counts the number of rows in a specified table or column.


16. Which SQL clause is used to filter records after grouping with GROUP BY?

  • A) WHERE
  • B) HAVING
  • C) FILTER
  • D) SELECT

Answer: B) HAVING
The HAVING clause is used to filter records after grouping them using GROUP BY.


17. Which of the following SQL statements is used to remove a table from a database?

  • A) DELETE TABLE
  • B) REMOVE TABLE
  • C) DROP TABLE
  • D) ERASE TABLE

Answer: C) DROP TABLE
The DROP TABLE statement is used to remove an entire table from the database.


18. What is the purpose of the SQL ALTER statement?

  • A) To delete records from a table
  • B) To modify the structure of an existing table
  • C) To insert new records into a table
  • D) To create a new database

Answer: B) To modify the structure of an existing table
The ALTER statement is used to modify the structure of a table, such as adding or deleting columns.


19. Which of the following is the correct SQL statement for inserting new records into a table?

  • A) ADD INTO table_name VALUES (value1, value2, value3);
  • B) INSERT INTO table_name VALUES (value1, value2, value3);
  • C) ADD RECORD INTO table_name;
  • D) INSERT VALUES INTO table_name (value1, value2, value3);

Answer: B) INSERT INTO table_name VALUES (value1, value2, value3);
The INSERT INTO statement is used to add new records into a table.


20. What is a foreign key in SQL?

  • A) A key used to identify a unique record in a table
  • B) A key used to establish a relationship between two tables
  • C) A key used to encrypt data
  • D) A key used to identify a record in a primary table

Answer: B) A key used to establish a relationship between two tables
A foreign key is a column or set of columns that links two tables together, enforcing referential integrity.


21. What does the DISTINCT keyword do?

  • A) Selects records with unique values in a column
  • B) Selects all records from a table
  • C) Orders records based on column values
  • D) Limits the number of records in a result

Answer: A) Selects records with unique values in a column
The DISTINCT keyword eliminates duplicate records from the result set.


22. Which of the following SQL functions is used to return the average value of a numeric column?

  • A) SUM()
  • B) AVG()
  • C) COUNT()
  • D) MIN()

Answer: B) AVG()
The AVG() function returns the average value of a numeric column.


23. What is the primary purpose of the UNION operator in SQL?

  • A) To combine the results of two or more queries
  • B) To join two tables
  • C) To filter duplicate records
  • D) To perform calculations

Answer: A) To combine the results of two or more queries
The UNION operator combines the result sets of two or more SELECT queries.


24. Which of the following is the correct syntax for deleting all rows from a table without removing the table?

  • A) DELETE * FROM table_name;
  • B) DELETE FROM table_name;
  • C) DROP FROM table_name;
  • D) REMOVE FROM table_name;

Answer: B) DELETE FROM table_name;
The DELETE FROM table_name; statement removes all rows from a table, but does not delete the table itself.


25. What is the use of the BETWEEN operator in SQL?

  • A) To filter rows that match a specific pattern
  • B) To filter rows that fall within a specified range
  • C) To filter rows that match a given value
  • D) To filter rows based on multiple conditions

Answer: B) To filter rows that fall within a specified range
The BETWEEN operator is used to filter results that fall within a specified range of values.


26. What is an SQL subquery?

  • A) A query that returns only one value
  • B) A query embedded inside another query
  • C) A query used to update records
  • D) A query used to create a table

Answer: B) A query embedded inside another query
An SQL subquery is a query nested inside another query, typically in the WHERE or FROM clause.


27. Which of the following is a correct way to write an SQL SELECT statement with an alias for a column?

  • A) SELECT column_name AS alias_name FROM table_name;
  • B) SELECT column_name -> alias_name FROM table_name;
  • C) SELECT column_name WITH alias_name FROM table_name;
  • D) SELECT column_name ALIAS alias_name FROM table_name;

Answer: A) SELECT column_name AS alias_name FROM table_name;
An alias is created using the AS keyword in a SELECT statement.


28. Which of the following is a correct SQL statement to modify the data in a table?

  • A) MODIFY table_name SET column1 = value1;
  • B) UPDATE table_name SET column1 = value1;
  • C) ALTER table_name MODIFY column1 = value1;
  • D) CHANGE table_name SET column1 = value1;

Answer: B) UPDATE table_name SET column1 = value1;
The UPDATE statement is used to modify data in an existing table.


29. Which of the following is NOT a valid SQL data type?

  • A) INT
  • B) VARCHAR
  • C) REAL
  • D) CHARACTER

Answer: D) CHARACTER
CHAR or VARCHAR are valid data types, but CHARACTER is not a valid SQL data type.


30. What does the NULL keyword represent in SQL?

  • A) A blank value
  • B) A zero value
  • C) A missing or undefined value
  • D) An invalid value

Answer: C) A missing or undefined value
The NULL keyword represents the absence of any value in a column.


31. Which SQL clause is used to return rows in a specific order?

  • A) GROUP BY
  • B) HAVING
  • C) ORDER BY
  • D) SELECT

Answer: C) ORDER BY
The ORDER BY clause sorts the result set in ascending or descending order based on one or more columns.


32. Which of the following SQL statements is used to add a new column to an existing table?

  • A) ADD COLUMN column_name TO table_name;
  • B) ALTER TABLE table_name ADD column_name data_type;
  • C) INSERT COLUMN INTO table_name;
  • D) MODIFY TABLE table_name ADD column_name data_type;

Answer: B) ALTER TABLE table_name ADD column_name data_type;
The ALTER TABLE statement is used to add a new column to an existing table.


33. What is the default sorting order of the ORDER BY clause?

  • A) Ascending (ASC)
  • B) Descending (DESC)
  • C) Random
  • D) Alphabetical

Answer: A) Ascending (ASC)
By default, the ORDER BY clause sorts results in ascending order.


34. Which function is used to return the number of rows in a table that match a specific condition?

  • A) COUNT()
  • B) SUM()
  • C) AVG()
  • D) MAX()

Answer: A) COUNT()
The COUNT() function returns the number of rows that match a specified condition.


35. What does the INSERT INTO statement do?

  • A) Modifies an existing record
  • B) Deletes a record from a table
  • C) Adds a new record to a table
  • D) Removes a column from a table

Answer: C) Adds a new record to a table
The INSERT INTO statement is used to add new rows of data into a table.


36. Which SQL statement is used to change the structure of a table?

  • A) UPDATE
  • B) MODIFY
  • C) ALTER
  • D) CHANGE

Answer: C) ALTER
The ALTER statement is used to modify the structure of a table, such as adding, dropping, or modifying columns.


37. What does the IS NULL condition do in SQL?

  • A) Finds records with NULL values
  • B) Finds records with non-NULL values
  • C) Finds records with empty strings
  • D) Finds records with zero values

Answer: A) Finds records with NULL values
The IS NULL condition is used to find rows where a column contains a NULL value.


38. What does the GROUP BY clause do in SQL?

  • A) Orders the result set
  • B) Groups rows that have the same values in specified columns
  • C) Filters rows
  • D) Joins multiple tables

Answer: B) Groups rows that have the same values in specified columns
The GROUP BY clause is used to group rows based on specified columns for aggregate functions.


39. What is a PRIMARY KEY in SQL?

  • A) A key that uniquely identifies each record in a table
  • B) A key used to establish a relationship between two tables
  • C) A key that stores encrypted data
  • D) A key used to restrict access to a database

Answer: A) A key that uniquely identifies each record in a table
A PRIMARY KEY is a column or combination of columns that uniquely identifies each record in a table.


40. What does the BETWEEN operator do in SQL?

  • A) Filters values that match a specific pattern
  • B) Filters records within a range of values
  • C) Filters records that are greater than a value
  • D) Filters records that are less than a value

Answer: B) Filters records within a range of values
The BETWEEN operator is used to filter records that fall within a specified range.


41. Which clause is used to combine two or more SELECT statements?

  • A) UNION
  • B) JOIN
  • C) GROUP BY
  • D) SELECT ALL

Answer: A) UNION
The UNION operator is used to combine the results of two or more SELECT queries.


42. What does TRUNCATE do in SQL?

  • A) Deletes records in a table and frees the space
  • B) Deletes records in a table without freeing space
  • C) Deletes the table itself
  • D) Modifies a column’s value

Answer: A) Deletes records in a table and frees the space
TRUNCATE removes all rows from a table and releases the space used by the table.


43. Which function is used to find the total sum of a numeric column?

  • A) COUNT()
  • B) SUM()
  • C) AVG()
  • D) MAX()

Answer: B) SUM()
The SUM() function is used to calculate the total sum of a numeric column.


44. Which SQL function is used to find the lowest value in a column?

  • A) MAX()
  • B) MIN()
  • C) TOP()
  • D) BOTTOM()

Answer: B) MIN()
The MIN() function returns the smallest value in a specified column.


45. What is the use of the LIKE operator in SQL?

  • A) To filter values with a specified pattern
  • B) To find values that match exactly
  • C) To check for NULL values
  • D) To join tables

Answer: A) To filter values with a specified pattern
The LIKE operator is used to search for a specified pattern in a column.


46. Which of the following is the correct SQL syntax for removing all records from a table?

  • A) DELETE FROM table_name;
  • B) REMOVE FROM table_name;
  • C) DROP ALL FROM table_name;
  • D) CLEAR TABLE table_name;

Answer: A) DELETE FROM table_name;
DELETE FROM table_name; removes all records from a table without deleting the table structure.


47. What is the purpose of an INDEX in SQL?

  • A) To speed up queries by providing quick access to rows in a table
  • B) To make sure records are unique
  • C) To calculate the sum of a column
  • D) To define the relationships between tables

Answer: A) To speed up queries by providing quick access to rows in a table
An INDEX is used to improve query performance by allowing quick retrieval of rows from a table.


48. Which of the following SQL statements is used to return the number of records in a result set?

  • A) COUNT()
  • B) NUM()
  • C) ROWS()
  • D) LENGTH()

Answer: A) COUNT()
The COUNT() function is used to count the number of rows in a result set.


49. Which operator is used in SQL to check whether a value is within a range?

  • A) IN
  • B) BETWEEN
  • C) LIKE
  • D) IS

Answer: B) BETWEEN
The BETWEEN operator is used to filter records that fall within a range of values.


50. Which of the following is the correct SQL syntax to rename a table?

  • A) RENAME TABLE old_table TO new_table;
  • B) ALTER TABLE old_table RENAME TO new_table;
  • C) MODIFY TABLE old_table TO new_table;
  • D) CHANGE TABLE old_table TO new_table;

Answer: B) ALTER TABLE old_table RENAME TO new_table;
The ALTER TABLE statement is used to rename a table in SQL.

Also Read: Cloud Computing MCQs for Examinations

You may also like to Read: Important Chemical Formula: for Competitive Exams

Leave a Comment