T4Tutorials .PK

SQL MCQs

Q#1: SQL stands for:
(A) Structured Query Language
(B) Standard Query Language
(C) Simple Query Language
(D) Sequential Query Language
Answer: (A) Structured Query Language

Q#2: Which SQL command is used to retrieve data from a table?
(A) SELECT
(B) INSERT
(C) UPDATE
(D) DELETE
Answer: (A) SELECT

Q#3: Which SQL command is used to add new records to a table?
(A) SELECT
(B) INSERT
(C) UPDATE
(D) DELETE
Answer: (B) INSERT

Q#4: Which SQL command is used to modify existing records?
(A) SELECT
(B) INSERT
(C) UPDATE
(D) DELETE
Answer: (C) UPDATE

Q#5: Which SQL command is used to remove records from a table?
(A) DELETE
(B) DROP
(C) TRUNCATE
(D) REMOVE
Answer: (A) DELETE

Q#6: Which SQL command removes the entire table structure?
(A) DELETE
(B) DROP
(C) TRUNCATE
(D) REMOVE
Answer: (B) DROP

Q#7: Which SQL command removes all data but keeps the table structure?
(A) DELETE
(B) DROP
(C) TRUNCATE
(D) REMOVE
Answer: (C) TRUNCATE

Q#8: Which clause is used to filter rows in SQL?
(A) WHERE
(B) HAVING
(C) ORDER BY
(D) GROUP BY
Answer: (A) WHERE

Q#9: Which clause is used to group rows based on a column?
(A) WHERE
(B) HAVING
(C) GROUP BY
(D) ORDER BY
Answer: (C) GROUP BY

Q#10: Which clause is used to filter groups after aggregation?
(A) WHERE
(B) HAVING
(C) GROUP BY
(D) ORDER BY
Answer: (B) HAVING

Q#11: Which clause is used to sort the result set?
(A) WHERE
(B) HAVING
(C) ORDER BY
(D) GROUP BY
Answer: (C) ORDER BY

Q#12: Which aggregate function returns the total number of rows?
(A) SUM
(B) COUNT
(C) AVG
(D) MAX
Answer: (B) COUNT

Q#13: Which aggregate function returns the sum of values?
(A) SUM
(B) COUNT
(C) AVG
(D) MIN
Answer: (A) SUM

Q#14: Which aggregate function returns the average value?
(A) SUM
(B) COUNT
(C) AVG
(D) MAX
Answer: (C) AVG

Q#15: Which aggregate function returns the maximum value?
(A) MIN
(B) MAX
(C) COUNT
(D) AVG
Answer: (B) MAX

Q#16: Which aggregate function returns the minimum value?
(A) MIN
(B) MAX
(C) COUNT
(D) SUM
Answer: (A) MIN

Q#17: Which SQL keyword is used to remove duplicate rows?
(A) UNIQUE
(B) DISTINCT
(C) PRIMARY
(D) FOREIGN
Answer: (B) DISTINCT

Q#18: Which constraint ensures uniqueness of a column?
(A) PRIMARY KEY
(B) FOREIGN KEY
(C) UNIQUE
(D) CHECK
Answer: (C) UNIQUE

Q#19: Which constraint ensures a column cannot have NULL values?
(A) PRIMARY KEY
(B) NOT NULL
(C) UNIQUE
(D) CHECK
Answer: (B) NOT NULL

Q#20: Which constraint establishes a relationship between two tables?
(A) PRIMARY KEY
(B) FOREIGN KEY
(C) UNIQUE
(D) NOT NULL
Answer: (B) FOREIGN KEY

Q#21: Which constraint ensures data satisfies a specific condition?
(A) CHECK
(B) NOT NULL
(C) UNIQUE
(D) FOREIGN KEY
Answer: (A) CHECK

Q#22: Which SQL command is used to create a new table?
(A) CREATE TABLE
(B) INSERT TABLE
(C) ADD TABLE
(D) MAKE TABLE
Answer: (A) CREATE TABLE

Q#23: Which SQL command is used to modify a table structure?
(A) MODIFY
(B) ALTER TABLE
(C) UPDATE TABLE
(D) CHANGE TABLE
Answer: (B) ALTER TABLE

Q#24: Which SQL command is used to remove a table completely?
(A) DELETE TABLE
(B) DROP TABLE
(C) TRUNCATE TABLE
(D) REMOVE TABLE
Answer: (B) DROP TABLE

Q#25: Which operator is used for pattern matching in SQL?
(A) LIKE
(B) MATCH
(C) PATTERN
(D) REGEX
Answer: (A) LIKE

Q#26: Which operator checks for a value within a set of values?
(A) IN
(B) EXISTS
(C) BETWEEN
(D) LIKE
Answer: (A) IN

Q#27: Which operator checks for a value within a range?
(A) IN
(B) EXISTS
(C) BETWEEN
(D) LIKE
Answer: (C) BETWEEN

Q#28: Which operator checks if a subquery returns any row?
(A) IN
(B) EXISTS
(C) BETWEEN
(D) LIKE
Answer: (B) EXISTS

Q#29: Which SQL keyword is used to combine results from two tables?
(A) JOIN
(B) UNION
(C) INTERSECT
(D) MERGE
Answer: (A) JOIN

Q#30: Inner join returns:
(A) Only matching rows from both tables
(B) All rows from first table
(C) All rows from second table
(D) All rows from both tables
Answer: (A) Only matching rows from both tables

Exit mobile version