1.What SQL statement is used to fetch data from a database?
A) INSERT
B) SELECT
C) UPDATE
D) DELETE
2. What does the WHERE keyword do in SQL in a query?
A) It defines what columns to return.
B) It filters rows on a condition.
C) It sorts the result set.
D) It joins more tables.
3. How would you select all the columns, i.e., all the columns from the “employees” table?
A) SELECT columns FROM employees;
B) SELECT * FROM employees;
C) SELECT ALL FROM employees;
D) SELECT ALL COLUMNS FROM employees;
4. What would the given SQL produce for you? SELECT name FROM customers WHERE age BETWEEN 30 AND 50;
A) Select names of customers under 30 years of age
B) Select the names of customers who are between the ages of 30 and 50.
C) Select all columns of customers aged between 30 and 50
D) None of the above
5. Which of the following operators in SQL are used to check for null values?
A) = NULL
B) IS NULL
C) NULL
D) EXISTS
6. How to avoid duplicate value repeats in query results?
A) UNIQUE keyword
B) DISTINCT keyword
C) FILTER keyword
D) EXCLUDE keyword
7. Which clause in SQL is used to sort data in Ascending/Descending order?
A) GROUP BY
B) ORDER BY
C) SORT BY
D) ARRANGE BY
8. Which of the following syntaxes is correct to insert a new record in the “products” table?
A) INSERT INTO products VALUES (101, ‘Laptop’, 750);
B) INSERT products (101, ‘Laptop’, 750);
C) ADD RECORD TO products (101, ‘Laptop’, 750);
D) INSERT TO products (101, ‘Laptop’, 750);
9. How would you raise all employees’ salaries in the “staff” table by 10%?
A) UPDATE staff SET salary = salary * 1.1;
B) MODIFY staff SET salary = salary * 1.1;
C) CHANGE staff salary TO salary * 1.1;
D) ALTER staff ADD 10 TO salary;
10. Which of the following SQL functions returns the total of a numeric column?
A) COUNT()
B) SUM()
C) AVERAGE()
D) TOTAL()
11. Which of the following is the correct syntax for a query to delete all rows where “status” is ‘inactive’?
A) REMOVE FROM table WHERE status = ‘inactive’;
B) DELETE FROM table WHERE status = ‘inactive’;
C) ERASE FROM table WHERE status = ‘inactive’;
D) DELETE ROWS FROM table WHERE status = ‘inactive’;
12. Which SQL keyword is used to group rows that have a common property?
A) GROUP BY
B) ORDER BY
C) HAVING
D) PARTITION BY
13. What does HAVING do?
A) It filters rows after it has grouped them.
B) It sorts rows in the result.
C. Group rows having similar values.
D) Joins Tables
14. Which of the following selects distinct job titles from the “employees” table?
A) SELECT ALL job_title FROM employees;
B) SELECT DISTINCT job_title FROM employees;
C) SELECT job_title FROM employees WHERE UNIQUE;
D) SELECT DISTINCT job_title FROM employees;
15. Which SQL statement below would create a table?
A) CREATE employees;
B) CREATE TABLE employees;
C) ADD TABLE employees;
D) MAKE TABLE employees;
16. What does the use of a foreign key in SQL do?
A) Uniquely identifies every record in the table
B) Relate tables on their relationships to one another
C) Stores data that is encrypted
D) Defines the default value of a column
17. When combining rows from two or more tables, which SQL term is used?
A) UNION
B) MERGE
C) COMBINE
D) LINK
18. What does the following query accomplish? SELECT COUNT(*) FROM orders;
A) The total number of columns in a table
B) The total number of rows in the table
C) The total number of orders beyond a certain value
D) None of the above
19. When creating a database, which SQL statement is used?
A) CREATE DATABASE database_name;
B) NEW DATABASE database_name;
C) ADD DATABASE database_name;
D) INSERT DATABASE database_name;
20. What does the LIMIT clause do in SQL?
A) It groups rows according to a condition
B) It limits the number of rows in the result set
C) It filters rows by a range of values
D) It orders rows by a condition
21. In SQL, which operator is used to match patterns?
A) LIKE
B) MATCH
C) PATTERN
D) SEARCH
22. How will you select the first 5 rows from any table?
A) SELECT * FROM table FETCH 5;
B) SELECT TOP 5 * FROM table;
C) SELECT * FROM table LIMIT 5;
D) Both B and C
23. Which SQL statement is used to alter the structure of an already existing table?
A) MODIFY TABLE
B) ALTER TABLE
C) UPDATE TABLE
D) CHANGE TABLE
24. What is the default sort order in SQL?
A) Ascending
B) Descending
C) Random
D) None
25. How will you join two tables if they share something in common?
A) CROSS JOIN
B) INNER JOIN
C) SELF JOIN
D) OUTER JOIN
26. What is the action of SELECT AVG(salary) FROM employees;?
A) Gives the sum of salaries of employees
B) Gives average salary of employees
C) Gives the minimum salary of employees
D) Gives the maximum salary of employees
27. Which SQL statement deletes duplicate records in a result set?
A) SELECT DISTINCT
B) SELECT UNIQUE
C) SELECT EXCLUSIVE
D) SELECT FILTER
28. What does TRUNCATE TABLE table_name do?
A) Deletes all records and resets the structure of the table
B) Deletes all records but saves the structure of the table
C) Deletes some records of the table
D) Completely delete the table
29. Which of the following is NOT a legitimate SQL constraint?
A) UNIQUE
B) INDEX
C) SORT
D) LINK
30. What does an index serve for in SQL?
A) A way to implement a foreign key
B) It increases the speed of a query
C) A column by default
D) To create a new table
31. Which of the following query is correct for using comparison operators in SQL?
A) SELECT sname, coursename FROM studentinfo WHERE age>50 and <80;
B) SELECT sname, coursename FROM studentinfo WHERE age>50 and age <80;
C) SELECT sname, coursename FROM studentinfo WHERE age>50 and WHERE age<80;
D) None of the above
32.How to select all data from studentinfo table starting the name from letter ‘r’?
A) SELECT * FROM studentinfo WHERE sname LIKE ‘r%’;
B) SELECT * FROM studentinfo WHERE sname LIKE ‘%r%’;
C) SELECT * FROM studentinfo WHERE sname LIKE ‘%r’;
D) SELECT * FROM studentinfo WHERE sname LIKE ‘_r%’;
33. Which of the following SQL query is correct for selecting the name of staffs from ‘tblstaff’ table where salary is 15,000 or 25,000?
A) SELECT sname from tblstaff WHERE salary IN (15000, 25000);
B) SELECT sname from tblstaff WHERE salary BETWEEN 15000 AND 25000;
C) Both A and B
D) None of the above
34. The SELECT statement, that retrieves all the columns from empinfo table name starting with d to p is ……………………..
A) SELECT ALL FROM empinfo WHERE ename like ‘[d-p]%’;
B) SELECT * FROM empinfo WHERE ename is ‘[d-p]%’;
C) SELECT * FROM empinfo WHERE ename like ‘[p-d]%’;
D) SELECT * FROM empinfo WHERE ename like ‘[d-p]%’;
35. Select a query that retrieves all of the unique countries from the student table?
A) SELECT DISTINCT coursename FROM studentinfo;
B) SELECT UNIQUE coursename FROM studentinfo;
C) SELECT DISTINCT coursename FROM TABLE studentinfo;
D) SELECT INDIVIDUAL coursename FROM studentinfo;
36. Which query is used for sorting data that retrieves the all the fields from empinfo table and listed them in the ascending order?
A) SELECT * FROM empinfo ORDER BY age;
B) SELECT * FROM empinfo ORDER age;
C) SELECT * FROM empinfo ORDER BY COLUMN age;
D) SELECT * FROM empinfo SORT BY age;
37. Select the right statement to insert values to the stdinfo table.
A) INSERT VALUES (“15”, “Hari Thapa”, 45, 5000) INTO stdinfo;
B) INSERT VALUES INTO stdinfo (“15”, “Hari Thapa”, 45, 5000);
C) INSERT stdinfo VALUES (“15”, “Hari Thapa”, 45, 5000);
D) INSERT INTO stdinfo VALUES (“15”, “Hari Thapa”, 45, 5000);
38. How to Delete records from studentinfo table with name of student ‘Hari Prasad’?
A) DELETE FROM TABLE studentinfo WHERE sname=’Hari Prasad’;
B) DELETE FROM studentinfo WHERE sname=’Hari Prasad’;
C) DELETE FROM studentinfo WHERE COLUMN sname=’Hari Prasad’;
D) DELETE FROM studentinfo WHERE sname LIKE ‘Hari Prasad’;
39. Constraint checking can be disabled in existing …………. and ………….. constraints so that any data you modify or add to the table is not checked against the constraint.
A) CHECK, FOREIGN KEY
B) DELETE, FOREIGN KEY
C) CHECK, PRIMARY KEY
D) PRIMARY KEY, FOREIGN KEY
40. ………………… joins two or more tables based on a specified column value not equaling a specified column value in another table.
A) OUTER JOIN
B) NATURAL JOIN
C) NON-EQUIJOIN
D) EQUIJOIN
We have created a quiz including MCQ of Structured Query Language(SQL) with basic SQL queries. Please take this quiz to test your knowledge on DBMS fundamentals.
Quiz for Fundamentals of DBMS
Answers:
- B) SELECT
- B) It filters rows on a condition.
- B) SELECT * FROM employees;
- B) Select the names of customers who are between the ages of 30 and 50.
- B) IS NULL
- B) DISTINCT keyword
- B) ORDER BY
- A) INSERT INTO products VALUES (101, ‘Laptop’, 750);
- A) UPDATE staff SET salary = salary * 1.1;
- B) SUM()
- B) DELETE FROM table WHERE status = ‘inactive’;
- A) GROUP BY
- A) It filters rows after it has grouped them.
- B) SELECT DISTINCT job_title FROM employees;
- B) CREATE TABLE employees;
- B) Relate tables on their relationships to one another
- A) UNION
- B) The total number of rows in the table
- A) CREATE DATABASE database_name;
- B) It limits the number of rows in the result set
- A) LIKE
- C) SELECT * FROM table LIMIT 5;
- B) ALTER TABLE
- A) Ascending
- B) INNER JOIN
- B) Gives average salary of employees
- A) SELECT DISTINCT
- A) Deletes all records and resets the structure of the table
- A) UNIQUE
- B) It increases the speed of a query
- B) SELECT sname, coursename FROM studentinfo WHERE age>50 and age <80;
- A) SELECT * FROM studentinfo WHERE sname LIKE ‘r%’;
- A) SELECT sname from tblstaff WHERE salary IN (15000, 25000);
- D) SELECT * FROM empinfo WHERE ename like ‘[d-p]%’;
- A) SELECT DISTINCT coursename FROM studentinfo;
- A) SELECT * FROM empinfo ORDER BY age;
- D) INSERT INTO stdinfo VALUES (“15”, “Hari Thapa”, 45, 5000);
- B) DELETE FROM studentinfo WHERE sname=’Hari Prasad’;
- A) CHECK, FOREIGN KEY
- C) NON-EQUIJOIN
Read Next: SQL MCQ of Structured Query Language With Answers set-3
Table of Contents
FAQs for MCQ of Structured Query Language (SQL)
What are MCQs of Structured Query Language?
MCQs of Structured Query Language are a form of assessment in SQL that measures one’s cognizance about concepts. It poses questions to which several answers are possible but again only one is correct. You will find huge applications for testing theoretical and practical SQL understanding in certification tests conducted on SQL.
Why should I Prepare MCQ of Structured Query Language for certification exams?
Practicing MCQ of Structured Query Language fortifies the concepts of SQL, helps learn how queries have to be framed, and recognizes common pitfalls. You will get insight into the form of questions for certification of examinations and should confidently and efficiently be used by practicing time management.
What topics are covered by this set on MCQ of Structured Query Language?
This set on MCQ of Structured Query Language touch on a wide range of topics: SQL statements such as SELECT and UNIQUE statements, constraints, joins, aggregate functions, and more.
Are the MCQ of Structured Query Language theory-based or practical in the Exam?
Most MCQ of Structured Query Language are scenario-based, and they test your practical understanding. Although some are theoretical, most will involve query analysis or solving real-world database problems.
Does practicing this MCQ of Structured Query Language help me with overall database skills?
Of course, practicing this MCQ of Structured Query Language enhances your understanding of database concepts, query optimization, and troubleshooting by serving as a platform to bridge the gap in theoretical and practical applications.
We have created a video on YouTube including MCQ of Structured Query Language(SQL) with basic SQL queries. Please watch the video and subscribe to our channel to get more videos on DBMS.
Read More: Collections of DBMS MCQ questions
Download: Free PDF E-book of DBMS MCQ questions