0% found this document useful (0 votes)
40 views28 pages

SQL MCQs for Practice and Learning

The document contains a series of multiple-choice questions (MCQs) related to SQL, categorized into easy, medium, and hard levels. Each question includes options, the correct answer, and a brief explanation of the answer. The topics cover various SQL concepts such as commands, functions, joins, constraints, and indexing.

Uploaded by

Pankaj Navale
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views28 pages

SQL MCQs for Practice and Learning

The document contains a series of multiple-choice questions (MCQs) related to SQL, categorized into easy, medium, and hard levels. Each question includes options, the correct answer, and a brief explanation of the answer. The topics cover various SQL concepts such as commands, functions, joins, constraints, and indexing.

Uploaded by

Pankaj Navale
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SQL mcq’s for PRA

🟢 EASY LEVEL (1–35)


1. Which SQL statement is used to fetch data from a database?
A. GET
B. OPEN
C. SELECT
D. FETCH
Answer: C
Explanation: SELECT retrieves data from tables.

2. Which clause is used to filter records?


A. GROUP BY
B. WHERE
C. ORDER BY
D. HAVING
Answer: B
Explanation: WHERE filters rows before grouping.

3. Which keyword removes duplicate values?


A. UNIQUE
B. DISTINCT
C. REMOVE
D. DELETE
Answer: B
Explanation: DISTINCT removes duplicates.
4. Which SQL command is used to delete a table?
A. DELETE
B. DROP
C. REMOVE
D. TRUNCATE
Answer: B
Explanation: DROP TABLE removes table structure and data.

5. What does COUNT(*) do?


A. Counts null values
B. Counts non-null values
C. Counts all rows
D. Counts unique rows
Answer: C
Explanation: Counts total rows including NULLs.

6. Which operator is used for pattern matching?


A. IN
B. LIKE
C. BETWEEN
D. EXISTS
Answer: B
Explanation: LIKE is used with % and _.

7. Which command is used to insert data?


A. ADD
B. INSERT INTO
C. PUT
D. UPDATE
Answer: B
Explanation: INSERT INTO adds records.

8. Which constraint ensures no duplicate values?


A. PRIMARY KEY
B. FOREIGN KEY
C. UNIQUE
D. CHECK
Answer: C
Explanation: UNIQUE prevents duplicate values.

9. Which clause sorts the result?


A. SORT
B. GROUP BY
C. ORDER BY
D. FILTER
Answer: C
Explanation: ORDER BY sorts results.

10. Which function returns the highest value?


A. MAX()
B. TOP()
C. HIGH()
D. UPPER()
Answer: A
Explanation: MAX() gives maximum value.

11. Default sorting order is:


A. DESC
B. RANDOM
C. ASC
D. NONE
Answer: C
Explanation: Default is ascending.

12. Which symbol represents single character wildcard?


A. %
B. *
C. _
D. ?
Answer: C
Explanation: _ matches exactly one character.

13. Which command removes all rows but keeps structure?


A. DELETE
B. DROP
C. TRUNCATE
D. REMOVE
Answer: C
Explanation: TRUNCATE is faster and non-recoverable.

14. Which keyword is used to rename a column?


A. CHANGE
B. AS
C. RENAME
D. MODIFY
Answer: B
Explanation: AS is used for aliasing.

15. Which function returns current date?


A. NOW()
B. CURDATE()
C. DATE()
D. GETDATE()
Answer: B
Explanation: MySQL uses CURDATE().

16. Which constraint ensures valid values?


A. UNIQUE
B. CHECK
C. DEFAULT
D. NOT NULL
Answer: B
Explanation: CHECK enforces conditions.
17. Which SQL keyword is case-insensitive?
A. Table names
B. Column names
C. Keywords
D. Values
Answer: C
Explanation: SQL keywords are not case-sensitive.

18. Which clause groups rows?


A. ORDER BY
B. GROUP BY
C. WHERE
D. JOIN
Answer: B
Explanation: GROUP BY groups rows.

19. Which command updates records?


A. MODIFY
B. UPDATE
C. CHANGE
D. ALTER
Answer: B
Explanation: UPDATE modifies existing data.
20. Which key uniquely identifies a record?
A. FOREIGN KEY
B. UNIQUE
C. PRIMARY KEY
D. CHECK
Answer: C
Explanation: Primary key uniquely identifies rows.

21. Which operator selects a range?


A. LIKE
B. BETWEEN
C. IN
D. EXISTS
Answer: B
Explanation: BETWEEN selects values in range.

22. Which keyword limits rows?


A. LIMIT
B. TOP
C. FETCH
D. ALL
Answer: A
Explanation: MySQL uses LIMIT.

23. Which function converts text to uppercase?


A. UPPER()
B. LOWER()
C. TOCHAR()
D. CAP()
Answer: A

24. Which clause filters groups?


A. WHERE
B. HAVING
C. GROUP BY
D. FILTER
Answer: B
Explanation: HAVING works on aggregated data.

25. Which SQL statement creates a table?


A. CREATE TABLE
B. NEW TABLE
C. MAKE TABLE
D. ADD TABLE
Answer: A

26. Which join returns matching records only?


A. LEFT JOIN
B. RIGHT JOIN
C. FULL JOIN
D. INNER JOIN
Answer: D

27. Which function returns total sum?


A. TOTAL()
B. ADD()
C. SUM()
D. COUNT()
Answer: C

28. Which data type stores text?


A. INT
B. CHAR
C. FLOAT
D. BOOLEAN
Answer: B

29. Which keyword is used to remove duplicates with aggregation?


A. DISTINCT
B. UNIQUE
C. GROUP BY
D. HAVING
Answer: A

30. Which function returns average?


A. AVG()
B. MEAN()
C. MID()
D. TOTAL()
Answer: A

31. Which clause is mandatory in SELECT?


A. FROM
B. WHERE
C. ORDER BY
D. GROUP BY
Answer: A

32. Which join returns all records from left table?


A. INNER
B. RIGHT
C. LEFT
D. FULL
Answer: C

33. Which SQL command changes table structure?


A. UPDATE
B. ALTER
C. MODIFY
D. CHANGE
Answer: B

34. Which function gives number of rows excluding NULL?


A. COUNT(*)
B. COUNT(col)
C. SUM()
D. AVG()
Answer: B

35. Which constraint disallows NULL?


A. UNIQUE
B. CHECK
C. NOT NULL
D. DEFAULT
Answer: C
🟢 MEDIUM LEVEL (36–70)
36. Difference between WHERE and HAVING?
A. Same
B. WHERE works on groups
C. HAVING works on aggregates
D. Both wrong
Answer: C
Explanation: WHERE filters rows, HAVING filters groups.

37. Which join returns unmatched rows from both tables?


A. INNER
B. FULL OUTER
C. LEFT
D. RIGHT
Answer: B

38. What is a foreign key?


A. Unique key
B. Primary key
C. Reference key
D. Index
Answer: C

39. Which normal form removes partial dependency?


A. 1NF
B. 2NF
C. 3NF
D. BCNF
Answer: B

40. Which index improves search performance?


A. PRIMARY
B. CLUSTERED
C. NON-CLUSTERED
D. ALL
Answer: D

41. Which command rolls back transaction?


A. COMMIT
B. SAVEPOINT
C. ROLLBACK
D. END
Answer: C

42. Which isolation level avoids dirty reads?


A. READ UNCOMMITTED
B. READ COMMITTED
C. REPEATABLE READ
D. SERIALIZABLE
Answer: B

43. What is a subquery?


A. Join
B. Query inside query
C. View
D. Function
Answer: B

44. Which subquery returns multiple rows?


A. Scalar
B. Correlated
C. Nested
D. Multi-row
Answer: D

45. Which operator works with subqueries?


A. IN
B. EXISTS
C. ANY
D. All
Answer: D

46. Which constraint enforces referential integrity?


A. UNIQUE
B. CHECK
C. FOREIGN KEY
D. DEFAULT
Answer: C

47. Which SQL command creates a view?


A. CREATE VIEW
B. MAKE VIEW
C. ADD VIEW
D. INSERT VIEW
Answer: A

48. Which view is updatable?


A. With JOIN
B. With GROUP BY
C. Simple view
D. Aggregate view
Answer: C

49. Which function handles NULL values?


A. NVL()
B. IFNULL()
C. COALESCE()
D. All
Answer: D

50. What is indexing?


A. Data duplication
B. Sorting data
C. Faster access
D. Data encryption
Answer: C

51. Which normal form removes transitive dependency?


A. 1NF
B. 2NF
C. 3NF
D. BCNF
Answer: C

52. Which clause is executed first?


A. SELECT
B. WHERE
C. FROM
D. ORDER BY
Answer: C

53. Which join uses common column?


A. INNER
B. NATURAL
C. LEFT
D. RIGHT
Answer: B

54. Which command grants permission?


A. ALLOW
B. GRANT
C. GIVE
D. ACCESS
Answer: B

55. Which keyword removes permission?


A. REMOVE
B. DELETE
C. REVOKE
D. DROP
Answer: C

56. What is a clustered index?


A. Separate structure
B. Sorted data
C. Duplicate index
D. Hash index
Answer: B

57. Which SQL function returns length of string?


A. LEN()
B. LENGTH()
C. SIZE()
D. COUNT()
Answer: B

58. Which clause is optional?


A. SELECT
B. FROM
C. WHERE
D. ALL
Answer: C

59. What is a transaction?


A. Single query
B. Logical unit of work
C. Backup
D. Index
Answer: B

60. Which SQL supports recursion?


A. JOIN
B. CTE
C. VIEW
D. TRIGGER
Answer: B

61. Which function rounds value?


A. ROUND()
B. FLOOR()
C. CEIL()
D. All
Answer: D

62. Which constraint auto-generates values?


A. CHECK
B. DEFAULT
C. AUTO_INCREMENT
D. UNIQUE
Answer: C

63. Which clause limits grouped result?


A. WHERE
B. HAVING
C. GROUP BY
D. ORDER
Answer: B

64. What is denormalization?


A. Remove redundancy
B. Add redundancy
C. Remove tables
D. Remove keys
Answer: B

65. Which join is fastest?


A. INNER
B. LEFT
C. RIGHT
D. FULL
Answer: A

66. Which SQL object stores compiled queries?


A. View
B. Procedure
C. Trigger
D. Index
Answer: B

67. Which trigger fires automatically?


A. SELECT
B. INSERT
C. UPDATE
D. All DML
Answer: D

68. Which keyword avoids NULL comparison issue?


A. =
B. !=
C. IS
D. LIKE
Answer: C

69. Which operator checks existence?


A. IN
B. EXISTS
C. ANY
D. ALL
Answer: B

70. Which join returns all records when no match?


A. INNER
B. OUTER
C. SELF
D. CROSS
Answer: B
🔴 HARD LEVEL (71–100)
71. Which isolation level prevents phantom reads?
Answer: SERIALIZABLE
Explanation: Highest isolation level.

72. Which index allows only one per table?


Answer: Clustered index

73. Which query runs once per row in outer query?


Answer: Correlated subquery

74. Which join produces Cartesian product?


Answer: CROSS JOIN

75. Which command creates save point?


Answer: SAVEPOINT

76. Which normal form removes multivalued dependency?


Answer: 4NF

77. Which SQL object enforces business rules?


Answer: TRIGGER
78. Which function replaces NULL with value?
Answer: COALESCE()

79. Which join compares table with itself?


Answer: SELF JOIN

80. Which clause is evaluated last?


Answer: ORDER BY

81. Which SQL keyword creates temporary result?


Answer: WITH (CTE)

82. Which index improves JOIN performance?


Answer: FOREIGN KEY index

83. Which SQL command is DDL?


Answer: ALTER

84. Which SQL command is TCL?


Answer: COMMIT
85. Which SQL command is DML?
Answer: INSERT

86. Which view cannot be updated?


Answer: Aggregate view

87. Which function returns rank?


Answer: RANK()

88. Which clause assigns row numbers?


Answer: ROW_NUMBER()

89. Which SQL feature improves performance by caching?


Answer: Stored Procedure

90. Which index uses hash structure?


Answer: Hash index

91. Which SQL avoids deadlock?


Answer: Proper transaction ordering

92. Which command renames table?


Answer: RENAME

93. Which constraint enforces domain integrity?


Answer: CHECK

94. Which SQL handles recursive hierarchy?


Answer: Recursive CTE

95. Which function returns nth highest salary?


Answer: DENSE_RANK()

96. Which join is costliest?


Answer: FULL OUTER JOIN

97. Which SQL avoids duplicate rows in UNION?


Answer: UNION

98. Which SQL keeps duplicates?


Answer: UNION ALL

99. Which index stores data physically?


Answer: Clustered index
100. Which SQL feature improves security?
Answer: GRANT / REVOKE

You might also like