Top SQL MCQ Questions to Boost Your Knowledge and Skills

Top SQL MCQ Questions to Boost Your Knowledge and Skills

23 Dec 2024
Question
77 Views
24 min read
Learn with an interactive course and practical hands-on labs

SQL Server Course

SQL MCQ Questions

Practicing SQL MCQ Questions is a great way to strengthen your understanding of SQL concepts, whether you're preparing for exams, interviews, or technical assessments. These questions cover topics like queries, joins, indexing, and more, helping you test and refine your knowledge. By solving SQL MCQ Questions, you can identify areas for improvement and gain the confidence to tackle real-world database challenges. Let’s explore the SQL Server tutorial to enhance your skills!

In the Interview tutorial, let's learn the top 100 most-asked SQL Interview Questions and clear your basic concept.

Read More:

Top 100 SQL MCQ Questions and Answers

Q 1. What does SQL stand for?

  • Structured Question Language
  • Structured Query Language
  • Simple Query Language
  • Standard Query Logic

Q 2. Which of the following is NOT a SQL command?

  • SELECT
  • INSERT
  • CREATE DATABASE TABLE
  • UPDATE

Q 3. Which SQL clause is used to filter the results of a query?

  • ORDER BY
  • WHERE
  • GROUP BY
  • HAVING
Read More: SQL WHERE Clause Explained: Filter Data with Precision

    Q 4. How do you select all columns from a table named "employees"?

    • SELECT all FROM employees;
    • SELECT employees FROM *;
    • SELECT * FROM employees;
    • SELECT * employees;

    Q 5. Which function is used to find the maximum value in SQL?

    • AVG()
    • MAX()
    • MIN()
    • SUM()

    Q 6. What is the purpose of the PRIMARY KEY?

    • To link two tables
    • To uniquely identify each row
    • To store null values
    • To enforce constraints
    Read More: Differences between Primary Key and Foreign Key

      Q 7. Which SQL keyword is used to sort the result-set?

      • SORT
      • ORDER BY
      • GROUP BY
      • FILTER

      Q 8. What is the correct syntax to insert a new record into a table?

      • INSERT TABLE employees VALUES (‘John’, 30);
      • INSERT INTO employees (‘John’, 30);
      • INSERT INTO employees VALUES (‘John’, 30);
      • INSERT employees INTO (‘John’, 30);

      Q 9. Which operator checks for a NULL value?

      • == NULL
      • NULL IS
      • IS NULL
      • EQUALS NULL

      Q 10. How do you update a column value in SQL?

      • MODIFY TABLE employees SET age=31;
      • UPDATE employees SET age=31 WHERE id=1;
      • CHANGE employees SET age=31;
      • ALTER employees age=31;

      Q 11. What does the COUNT() function return?

      • Sum of column values
      • Number of rows
      • Average value
      • Highest value

      Q 12. Which clause is used with aggregate functions to group rows?

      • WHERE
      • GROUP BY
      • ORDER BY
      • HAVING

      Q 13. What is a FOREIGN KEY?

      • A unique identifier for each row
      • A key that references a primary key in another table
      • A mandatory column
      • A table constraint

      Q 14. How do you remove duplicates from a query result?

      • REMOVE DUPLICATES
      • DELETE DUPLICATE
      • SELECT DISTINCT
      • SELECT UNIQUE

      Q 15. What does the SQL JOIN clause do?

      • Combines two or more databases
      • Combines rows from two or more tables
      • Deletes rows from tables
      • Groups records
      Read More: Different Types of SQL Joins

        Q 16. Which JOIN returns all records from both tables, matching where possible?

        • INNER JOIN
        • LEFT JOIN
        • FULL JOIN
        • CROSS JOIN
        Read More: Full Outer Join in SQL: A Comprehensive Guide

          Q 17. How do you delete a table in SQL?

          • DELETE TABLE table_name;
          • DROP DATABASE table_name;
          • DROP TABLE table_name;
          • REMOVE TABLE table_name;

          Q 18. Which SQL keyword prevents duplicate rows in a result?

          • UNIQUE
          • DISTINCT
          • SELECT DISTINCT
          • REMOVE DUPLICATES

          Q 19. What is the default sorting order in SQL?

          • Descending
          • Ascending
          • Random
          • Alphabetical

          Q 20. Which SQL command is used to create a new table?

          • ADD TABLE
          • INSERT TABLE
          • CREATE TABLE
          • NEW TABLE
          Read More: What are the 5 Basic SQL Commands?

            Q 21. How do you fetch the first 10 rows from a table?

            • SELECT 10 FROM table_name;
            • SELECT * FROM table_name WHERE ROWNUM < 10;
            • SELECT * FROM table_name LIMIT 10;
            • SELECT TOP 10 *;

            Q 22. Which function returns the current date in SQL?

            • CURRDATE()
            • DATE()
            • CURRENT_DATE()
            • NOW()

            Q 23. What does the LIKE operator do?

            • Compares two tables
            • Filters rows based on a pattern
            • Checks for NULL values
            • Joins rows

            Q 24. How do you rename a table?

            • ALTER TABLE old_name RENAME TO new_name;
            • RENAME TABLE old_name TO new_name;
            • ALTER TABLE old_name RENAME TO new_name;
            • UPDATE TABLE old_name;

            Q 25. Which function calculates the total sum of a column?

            • AVG()
            • MAX()
            • SUM()
            • COUNT()

            Q 26. Which SQL clause is used to filter group rows?

            • WHERE
            • HAVING
            • ORDER BY
            • GROUP BY

            Q 27. How do you add a new column to an existing table?

            • ADD COLUMN table_name;
            • ALTER TABLE table_name ADD column_name datatype;
            • UPDATE COLUMN table_name;
            • INSERT COLUMN table_name;

            Q 28. Which command is used to remove a row in a table?

            • REMOVE ROW table_name;
            • DELETE ROW table_name;
            • DELETE FROM table_name WHERE condition;
            • DROP ROW table_name;

            Q 29. What does the DISTINCT keyword do in SQL?

            • Filters rows
            • Returns unique values
            • Removes duplicate values from result set
            • Orders results

            Q 30. Which SQL function is used to return the current time?

            • NOW()
            • CURRENT_TIME()
            • TIME()
            • CLOCK()
            Read More: Different Types of SQL Server Functions

              Q 31. What is the result of a LEFT JOIN?

              • Returns all rows from the right table
              • Returns matching rows from both tables
              • Returns all rows from the left table, matching rows from the right table
              • Returns non-matching rows from both tables
              Read More: Understanding LEFT JOIN in SQL: A Simple Guide

                Q 32. Which of the following is true about an INNER JOIN?

                • It returns rows where there is no match between the tables
                • It returns rows when there is a match between the tables
                • It returns all rows from both tables
                • It returns only rows from the left table
                Read More: Inner Join in SQL: How It Works

                  Q 33. Which command is used to change an existing column's datatype in SQL?

                  • UPDATE COLUMN datatype;
                  • ALTER COLUMN datatype;
                  • ALTER TABLE table_name MODIFY column_name new_datatype;
                  • CHANGE COLUMN datatype;

                  Q 34. Which operator is used to compare a value to a specified range of values?

                  • IN
                  • BETWEEN
                  • LIKE
                  • IS

                  Q 35. What does the "IS NOT NULL" condition do?

                  • Checks if the column value is empty
                  • Checks if the column value is not NULL
                  • Checks if the column value is NULL
                  • Checks if the column is not updated

                  Q 36. How do you create an index on a table in SQL?

                  • INDEX table_name;
                  • CREATE INDEX index_name ON table_name(column_name);
                  • CREATE INDEX index_name ON table_name(column_name);
                  • ALTER TABLE table_name ADD INDEX;

                  Q 37. Which SQL statement is used to retrieve unique records from a table?

                  • SELECT ALL
                  • SELECT DISTINCT
                  • SELECT DISTINCT
                  • SELECT NO_DUPLICATES

                  Q 38. How do you specify the order of rows in SQL?

                  • WITH ORDER BY
                  • ORDER BY column_name
                  • ORDER COLUMN
                  • ARRANGE BY column_name

                  Q 39. What is the result of an OUTER JOIN?

                  • It returns only matching rows
                  • It returns all rows from both tables
                  • It returns all rows from one table and matching rows from the other table
                  • It returns only non-matching rows
                  Read More: Understanding Outer Join in SQL

                    Q 40. What is a subquery in SQL?

                    • A query that uses another query inside it
                    • A query that is nested inside another query
                    • A query with no conditions
                    • A query with multiple joins

                    Q 41. Which clause is used to remove duplicates after grouping?

                    • HAVING
                    • DISTINCT
                    • GROUP BY
                    • WHERE

                    Q 42. Which of the following keywords is used for pattern matching?

                    • LIKE
                    • LIKE
                    • PATTERN
                    • SEARCH

                    Q 43. How can you list all tables in a SQL database?

                    • SHOW ALL TABLES;
                    • SHOW TABLES;
                    • SELECT TABLES;
                    • LIST TABLES;

                    Q 44. How do you combine two results sets from different queries in SQL?

                    • UNION ALL
                    • UNION
                    • JOIN
                    • APPEND

                    Q 45. What is the purpose of the SQL GROUP BY clause?

                    • Groups rows that have the same values
                    • Groups rows together based on column values
                    • Sorts rows by column values
                    • Combines tables based on common columns

                    Q 46. What is an alias in SQL?

                    • Shortened form of a table name
                    • Temporary name for a table or column
                    • Permanent name for a column
                    • Abbreviated SQL statement

                    Q 47. Which SQL function returns the length of a string?

                    • LENGTH()
                    • LEN()
                    • COUNT()
                    • STRING_LENGTH()

                    Q 48. How do you insert multiple rows into a table in SQL?

                    • INSERT INTO table_name VALUES (value1), (value2);
                    • INSERT INTO table_name VALUES (value1);
                    • INSERT INTO table_name (column1, column2) VALUES (value1, value2), (value3, value4);
                    • INSERT MULTIPLE INTO table_name;

                    Q 49. What is the default value of a column if not specified?

                    • NULL
                    • NULL
                    • 0
                    • Empty string

                    Q 50. How do you delete all rows from a table without deleting the table itself?

                    • DROP TABLE table_name;
                    • REMOVE FROM table_name;
                    • TRUNCATE TABLE table_name;
                    • TRUNCATE TABLE table_name;

                    Q 51. How do you return the current system date and time in SQL?

                    • GETDATE()
                    • CURRENT_TIME()
                    • NOW()
                    • DATE()

                    Q 52. Which SQL statement is used to add a constraint to a column?

                    • ALTER TABLE table_name ADD CONSTRAINT constraint_name;
                    • CREATE CONSTRAINT constraint_name;
                    • ALTER TABLE table_name ADD CONSTRAINT constraint_name column_name;
                    • INSERT CONSTRAINT;

                    Q 53. Which SQL clause is used to combine rows from two or more tables?

                    • CONCATENATE
                    • JOIN
                    • UNION
                    • MERGE

                    Q 54. What does the SQL IN operator do?

                    • Matches a value to a range
                    • Checks for pattern match
                    • Checks if a value exists within a set of values
                    • Checks for equality

                    Q 55. What is the default sorting order in an ORDER BY clause?

                    • Descending
                    • Ascending
                    • Alphabetical
                    • Numerical

                    Q 56. Which SQL clause is used to filter the results of a query based on the grouped data?

                    • GROUP BY
                    • ORDER BY
                    • HAVING
                    • HAVING

                    Q 57. Which SQL clause is used to group rows in a SELECT statement?

                    • WHERE
                    • ORDER BY
                    • GROUP BY
                    • HAVING

                    Q 58. What is the purpose of the SQL ALTER command?

                    • To delete a table
                    • To modify the structure of a database
                    • To modify the structure of an existing table
                    • To remove data from a table

                    Q 59. What is the correct SQL statement to get all columns from a table named "products" where the price is greater than 100?

                    • SELECT * FROM products WHERE price > 100;
                    • SELECT products WHERE price > 100;
                    • SELECT * FROM products WHERE price > 100;
                    • SELECT price FROM products WHERE price > 100;

                    Q 60. Which command is used to change the value of an existing row in SQL?

                    • MODIFY
                    • CHANGE
                    • UPDATE
                    • ALTER

                    Q 61. How do you remove a column from a table in SQL?

                    • DELETE COLUMN column_name;
                    • ALTER TABLE table_name DROP COLUMN column_name;
                    • REMOVE COLUMN column_name;
                    • DROP COLUMN table_name;

                    Q 62. What is the correct syntax for using the SQL UNION operator?

                    • SELECT column FROM table1 UNION SELECT column FROM table2;
                    • SELECT * FROM table1 UNION SELECT * FROM table2;
                    • SELECT column1 FROM table1 UNION SELECT column2 FROM table2;
                    • JOIN SELECT table1 UNION table2;

                    Q 63. What is a subquery in SQL?

                    • A query that runs independently
                    • Query that retrieves only one column
                    • A query that is nested inside another query
                    • Query that joins two tables

                    Q 64. What SQL clause is used to restrict the number of rows returned by a query?

                    • TOP
                    • LIMIT
                    • LIMIT
                    • OFFSET

                    Q 65. How do you delete all rows from a table without removing the table structure?

                    • DELETE TABLE table_name;
                    • TRUNCATE TABLE table_name;
                    • TRUNCATE TABLE table_name;
                    • DROP TABLE table_name;

                    Q 66. Which of the following SQL statements is used to create a new table?

                    • INSERT INTO
                    • NEW TABLE
                    • CREATE TABLE
                    • ALTER TABLE

                    Q 67. What SQL keyword is used to prevent duplicate rows from appearing in a result?

                    • UNIQUE
                    • FILTER
                    • DISTINCT
                    • REMOVE

                    Q 68. How do you retrieve the highest value from a column?

                    • MAX()
                    • MAX()
                    • SUM()
                    • AVG()

                    Q 69. Which of the following keywords is used to change the value of an existing column?

                    • MODIFY
                    • ALTER
                    • UPDATE
                    • CHANGE

                    Q 70. Which of the following SQL statements is used to combine the result sets of two queries?

                    • UNION
                    • JOIN
                    • INTERSECT
                    • CONCAT

                    Q 71. What SQL statement is used to delete data from a table?

                    • REMOVE
                    • DELETE
                    • DROP
                    • REMOVE ROW

                    Q 72. How do you find the number of rows in a table?

                    • COUNT(*)
                    • COUNT()
                    • SIZE()
                    • NUM()

                    Q 73. What is the correct syntax to update a record in a table?

                    • UPDATE table_name SET column_name = value;
                    • SET table_name column_name = value;
                    • UPDATE table_name SET column_name = value WHERE condition;
                    • CHANGE table_name SET column_name = value;

                    Q 74. Which SQL clause is used to sort the result set in ascending or descending order?

                    • ORDER BY
                    • GROUP BY
                    • ORDER BY
                    • SORT

                    Q 75. What keyword is used to create a new database in SQL?

                    • CREATE DATABASE
                    • CREATE DATABASE
                    • NEW DATABASE
                    • MAKE DATABASE

                    Q 76. Which of the following is not a valid SQL data type?

                    • VARCHAR
                    • STRING
                    • INT
                    • FLOAT

                    Q 77. How can you combine two tables in SQL based on a related column?

                    • JOIN
                    • UNION
                    • JOIN
                    • MATCH

                    Q 78. Which of the following is used to define a primary key in SQL?

                    • PRIMARY
                    • PRIMARY KEY
                    • KEY
                    • UNIQUE

                    Q 79. What does SQL SELECT DISTINCT do?

                    • Removes all rows from the result
                    • Removes duplicate rows from the result
                    • Sorts the result
                    • Displays all columns

                    Q 80. Which function is used to calculate the sum of a column?

                    • SUM()
                    • COUNT()
                    • SUM()
                    • TOTAL()

                    Q 81. What is the purpose of the SQL HAVING clause?

                    • To filter rows before grouping
                    • To define the structure of a group
                    • To filter groups after grouping
                    • To filter rows

                    Q 82. What is the correct syntax for a CASE expression in SQL?

                    • SELECT CASE WHEN condition THEN result;
                    • CASE WHEN condition THEN result ELSE alternative;
                    • CASE WHEN condition THEN result ELSE alternative END;
                    • IF condition THEN result ELSE alternative;
                    Read More: SQL HAVING Clause Explained: Filter Your Data Like a Pro

                      Q 83. How can you retrieve all columns from the "employees" table in SQL?

                      • SELECT * FROM employees;
                      • SELECT * FROM employees;
                      • SHOW COLUMNS FROM employees;
                      • SELECT all FROM employees;

                      Q 84. How can you create an index on a table column?

                      • CREATE INDEX index_name ON table_name;
                      • CREATE INDEX index_name ON table_name (column_name);
                      • CREATE INDEX index_name ON table_name (column_name);
                      • INDEX table_name (column_name);

                      Q 85. How do you remove a table from a database?

                      • REMOVE TABLE table_name;
                      • DELETE TABLE table_name;
                      • DROP TABLE table_name;
                      • DROP TABLE table_name;

                      Q 86. What does SQL LIKE operator do?

                      • Matches exactly
                      • Matches within a range
                      • Matches patterns in a column
                      • Matches numbers

                      Q 87. What does the COUNT() function do?

                      • Counts the distinct rows
                      • Counts the number of rows
                      • Counts the columns
                      • Counts the sum of rows

                      Q 88. Which SQL function is used to return the current date in a query?

                      • GETDATE()
                      • NOW()
                      • CURRENT_DATE()
                      • DATE()

                      Q 89. Which of the following SQL clauses is used to combine two SELECT queries?

                      • JOIN
                      • UNION
                      • UNION
                      • INTERSECT

                      Q 90. What is the use of SQL GROUP BY clause?

                      • To filter data
                      • To sort data
                      • To group rows that have the same values
                      • To limit the data

                      Q 91. Which keyword is used to sort the result set in descending order?

                      • ORDER BY DESC
                      • DESCENDING
                      • ORDER BY column DESC
                      • ORDER DESC

                      Q 92. How do you create a new user in SQL?

                      • CREATE USER user_name;
                      • CREATE USER user_name WITH PASSWORD;
                      • NEW USER user_name;
                      • ADD USER user_name;

                      Q 93. What does the SQL INNER JOIN clause do?

                      • Returns matching rows from both tables
                      • Returns only rows that have matching values in both tables
                      • Returns all rows from both tables
                      • Returns all rows from the first table

                      Q 94. How can you ensure that a column contains only unique values in SQL?

                      • UNIQUE constraint
                      • PRIMARY KEY constraint
                      • UNIQUE constraint
                      • NOT NULL constraint

                      Q 95. What is the purpose of the SQL EXISTS operator?

                      • Checks if a column exists
                      • Returns true if subquery returns any result
                      • Returns true if a subquery returns any rows
                      • Filters results

                      Q 96. What does the SQL NOT operator do?

                      • Negates a condition
                      • Negates a condition
                      • Changes the value
                      • Filters the rows

                      Q 97. What is a foreign key in SQL?

                      • Unique identifier for a table
                      • A column in one table that refers to the primary key of another table
                      • Key used for indexing
                      • The column that is automatically generated

                      Q 98. What does the SQL LIMIT clause do?

                      • Limits the number of rows returned
                      • Limits the number of rows returned
                      • Restricts the column selection
                      • Defines the maximum number of columns

                      Q 99. How do you rename a table in SQL?

                      • RENAME TABLE table_name TO new_table_name;
                      • ALTER TABLE table_name RENAME TO new_table_name;
                      • CHANGE TABLE table_name TO new_table_name;
                      • MODIFY TABLE table_name TO new_table_name;

                      Q 100. How do you create a backup of a database in SQL?

                      • BACKUP DATABASE
                      • CREATE DATABASE BACKUP
                      • BACKUP DATABASE database_name TO 'file_path';
                      • COPY DATABASE
                      Conclusion

                      In conclusion, SQL MCQ questions are a great way to test your knowledge and understanding of SQL concepts. Whether you're preparing for an interview, an exam, or simply trying to enhance your SQL skills, practicing with SQL MCQ questions can help you identify areas for improvement. By regularly challenging yourself with these SQL MCQ questions, you will develop a deeper grasp of SQL syntax, functions, and queries, ultimately making you more proficient in database management and development.

                      ScholarHat understands how hard & challenging it can be for a fresher or a less experienced candidate to even get their first job. Our masterclasses have been created to help you learn and immerse yourself in the latest technology trends. Join our master classes to upgrade your tech skills with the latest skills trends, design, and practices.

                        FAQs

                        The DISTINCT keyword is used to eliminate duplicate rows from the result set. It ensures that only unique values are returned for the specified columns. For example, if a table has multiple identical records, using SELECT DISTINCT will return only one instance of each unique record.

                        The EXISTS operator is used to check whether a subquery returns any results. It returns TRUE if the subquery returns at least one row, otherwise FALSE. 

                        The CASE statement is used to implement conditional logic in SQL queries. It allows you to return different values based on specific conditions, similar to an IF-THEN-ELSE construct in programming languages.

                        The COALESCE function returns the first non-NULL value from the list of arguments. It is useful for handling NULL values in data. 

                        A composite key is a primary key that consists of more than one column. It is used when no single column can uniquely identify a row in the table. 

                        Take our Sqlserver skill challenge to evaluate yourself!

                        In less than 5 minutes, with our skill challenge, you can identify your knowledge gaps and strengths in a given skill.

                        GET FREE CHALLENGE

                        Share Article
                        About Author
                        Shailendra Chauhan (Microsoft MVP, Founder & CEO at ScholarHat)

                        Shailendra Chauhan, Founder and CEO of ScholarHat by DotNetTricks, is a renowned expert in System Design, Software Architecture, Azure Cloud, .NET, Angular, React, Node.js, Microservices, DevOps, and Cross-Platform Mobile App Development. His skill set extends into emerging fields like Data Science, Python, Azure AI/ML, and Generative AI, making him a well-rounded expert who bridges traditional development frameworks with cutting-edge advancements. Recognized as a Microsoft Most Valuable Professional (MVP) for an impressive 9 consecutive years (2016–2024), he has consistently demonstrated excellence in delivering impactful solutions and inspiring learners.

                        Shailendra’s unique, hands-on training programs and bestselling books have empowered thousands of professionals to excel in their careers and crack tough interviews. A visionary leader, he continues to revolutionize technology education with his innovative approach.
                        Accept cookies & close this