wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

SQL MCQs - Class 12

Total questions: 55

Worksheet time: 28mins

Name
Class
Date
1.

What is the purpose of an INNER JOIN in SQL?

a)

To update records in a table.

b)

To create a new table from existing tables.

c)

To delete records from a table.

d)

To retrieve matching records from two or more tables.

2.

Which SQL function is used to count the number of rows in a table?

a)

MAX()

b)

COUNT()

c)

AVG()

d)

SUM()

3.

What data type would you use for a column that stores dates?

a)

INTEGER

b)

DATE or DATETIME

c)

BOOLEAN

d)

STRING

4.

How do you select all columns from a table named 'employees'?

a)

GET * FROM employees;

b)

FETCH * FROM employees;

c)

SELECT * FROM employees;

d)

SELECT ALL FROM employees;

5.

What is the function of the WHERE clause in an SQL statement?

a)

To filter records based on specified conditions.

b)

To create new records in the database.

c)

To sort records in ascending order.

d)

To join multiple tables together.

6.

What type of JOIN returns all records from the left table and matched records from the right table?

a)

FULL OUTER JOIN

b)

LEFT JOIN

c)

RIGHT JOIN

d)

INNER JOIN

7.

Which SQL function is used to find the maximum value in a column?

a)

COUNT()

b)

MIN()

c)

SUM()

d)

MAX()

8.

What is the default data type for a column that stores text in SQL?

a)

CHAR

b)

TEXT

c)

STRING

d)

VARCHAR

9.

How do you filter records in SQL using a specific condition?

a)

Utilize the JOIN clause to combine multiple tables.

b)

Apply the GROUP BY clause to summarize data.

c)

Use the WHERE clause to filter records based on a specific condition.

d)

Use the SELECT statement to retrieve all records.

10.

What is the purpose of the GROUP BY clause in SQL?

a)

To group rows that have the same values in specified columns and perform aggregate functions on them.

b)

To sort rows in ascending or descending order.

c)

To create new tables from existing data.

d)

To filter rows based on specific conditions.

11.

What type of JOIN would you use to combine rows from two tables based on a related column?

a)

RIGHT JOIN

b)

LEFT JOIN

c)

INNER JOIN

d)

FULL OUTER JOIN

12.

Which SQL function would you use to calculate the average of a numeric column?

a)

SUM()

b)

COUNT()

c)

AVG()

d)

MAX()

13.

What is the difference between CHAR and VARCHAR data types?

a)

CHAR is variable-length; VARCHAR is fixed-length.

b)

VARCHAR is used for numeric data types; CHAR is for text.

c)

CHAR can store more data than VARCHAR.

d)

CHAR is fixed-length; VARCHAR is variable-length.

14.

How do you update a record in a table named 'products'?

a)

INSERT INTO products VALUES (new_value) WHERE condition;

b)

DELETE FROM products WHERE condition;

c)

UPDATE products SET column_name = new_value WHERE condition;

d)

SELECT * FROM products WHERE condition;

15.

What is the purpose of the ORDER BY clause in SQL?

a)

To limit the number of rows returned by a query.

b)

To filter the result set of a query.

c)

To group the result set of a query.

d)

To sort the result set of a query.

16.

What SQL statement is used to remove a record from a table?

a)

REMOVE FROM table_name WHERE condition;

b)

DROP table_name WHERE condition;

c)

ERASE FROM table_name WHERE condition;

d)

DELETE FROM table_name WHERE condition;

17.

What is the purpose of the HAVING clause in SQL?

a)

To join multiple tables together.

b)

To filter records after grouping.

c)

To filter records before grouping.

d)

To sort the result set of a query.

18.

Which SQL command is used to create a new table?

a)

ADD TABLE table_name;

b)

MAKE TABLE table_name;

c)

NEW TABLE table_name;

d)

CREATE TABLE table_name;

19.

Which SQL command is used to modify existing records in a table?

a)

EDIT table_name SET column_name = value;

b)

UPDATE table_name SET column_name = value;

c)

CHANGE table_name SET column_name = value;

d)

ALTER table_name SET column_name = value;

20.

What is the purpose of the DISTINCT keyword in SQL?

a)

To limit the number of rows returned by a query.

b)

To sort the result set in descending order.

c)

To return only unique values from a column.

d)

To group rows that have the same values.

21.

What is the full form of SQL?

a)

Structured Query Logic

b)

Standard Query Language

c)

System Query Language

d)

Structured Query Language

22.

Which SQL clause is used to filter records?

a)

GROUP BY

b)

FILTER

c)

WHERE

d)

ORDER BY

23.

Which command is used to create a new database?

a)

CREATE DATABASE

b)

MAKE DATABASE

c)

CREATE TABLE

d)

ADD DATABASE

24.

Which SQL command is used to add a new column to an existing table?

a)

ADD COLUMN

b)

ALTER TABLE

c)

MODIFY TABLE

d)

UPDATE TABLE

25.

Which command is used to insert data into a table?

a)

INSERT INTO

b)

APPEND ROW

c)

ADD RECORD

d)

NEW ENTRY

26.

Which SQL function is used to get the total sum of values in a column?

a)

ADD()

b)

SUM()

c)

COUNT()

d)

TOTAL()

27.

Which clause is used to eliminate duplicate rows from output?

a)

REMOVE DUPLICATES

b)

FILTER

c)

DISTINCT

d)

UNIQUE

28.

Which SQL function is used to find the highest and lowest values in a column?

a)

TOP() and BOTTOM()

b)

MAX() and MIN()

c)

FIRST() and LAST()

d)

HIGH() and LOW()

29.

Which SQL clause is used for sorting records?

a)

SORT BY

b)

ARRANGE BY

c)

ORDER BY

d)

GROUP BY

30.

What is the default order of sorting using ORDER BY?

a)

No default order

b)

Random

c)

Descending

d)

Ascending

31.

Which SQL keyword is used to delete all records in a table without deleting the structure?

a)

REMOVE RECORDS

b)

DROP TABLE

c)

TRUNCATE TABLE

d)

DELETE FROM

32.

Which SQL clause is used for pattern matching?

a)

REGEXP

b)

SEARCH

c)

LIKE

d)

MATCH

33.

Which SQL keyword is used to find NULL values?

a)

= NULL

b)

IS NULL

c)

== NULL

d)

NULL

34.

Which SQL statement is used to modify existing records?

a)

ALTER

b)

MODIFY

c)

UPDATE

d)

CHANGE

35.

Which SQL clause is used to group data based on a specific column?

a)

GROUP BY

b)

ORDER BY

c)

SORT BY

d)

AGGREGATE

36.

Which SQL clause is used to group data based on a specific column?

a)

GROUP BY

b)

ORDER BY

c)

SORT BY

d)

AGGREGATE

37.

Which SQL function calculates the number of records?

a)

COUNT()

b)

SUM()

c)

NUMBER()

d)

TOTAL()

38.

Which SQL constraint ensures that values in a column are unique?

a)

FOREIGN KEY

b)

DEFAULT

c)

UNIQUE

d)

PRIMARY KEY

39.

Which SQL function returns the number of characters in a string?

a)

SIZE()

b)

LENGTH()

c)

STRLEN()

d)

COUNT()

40.

Which SQL clause is used to filter records after grouping?

a)

HAVING

b)

WHERE

c)

ORDER BY

d)

GROUP BY

41.

What is the function of the FOREIGN KEY constraint?

a)

Prevents NULL values

b)

Links data between tables

c)

Ensures unique values

d)

Deletes records automatically

42.

Which SQL constraint is used to set a default value for a column?

a)

PRIMARY KEY

b)

DEFAULT

c)

AUTO_INCREMENT

d)

CHECK

43.

Which SQL operator is used to find a range of values?

a)

RANGE

b)

IN

c)

LIMIT

d)

BETWEEN

44.

Which SQL function rounds a number to a specified decimal place?

a)

TRUNCATE()

b)

CEIL()

c)

FLOOR()

d)

ROUND()

45.

Which SQL function returns the absolute value of a number?

a)

ABS()

b)

ROUND()

c)

CEIL()

d)

MOD()

46.

Which SQL function returns the highest date from a column?

a)

MAX()

b)

HIGH()

c)

LAST()

d)

LATEST()

47.

Which SQL function is used to find the total number of rows in a table?

a)

ROWS()

b)

TOTAL()

c)

COUNT(*)

d)

NUMBER()

48.

Which SQL function converts a value into uppercase?

a)

CAPITALIZE()

b)

UPPER()

c)

CASE()

d)

TOUPPER()

49.

Which SQL statement is used to delete a particular column from a table?

a)

CLEAR COLUMN

b)

REMOVE COLUMN

c)

ALTER TABLE DROP COLUMN

d)

DELETE COLUMN

50.

Which SQL function returns the current system date?

a)

TODAY()

b)

NOW()

c)

GETDATE()

d)

CUR_DATE()

51.

Which SQL constraint ensures that a column cannot have NULL values?

a)

PRIMARY KEY

b)

CHECK

c)

NOT NULL

d)

FOREIGN KEY

52.

Which SQL function removes leading and trailing spaces from a string?

a)

TRIM()

b)

RTRIM()

c)

LTRIM()

d)

CLEAN()

53.

Which SQL statement is used to remove a table from a database?

a)

DELETE TABLE

b)

CLEAR TABLE

c)

REMOVE TABLE

d)

DROP TABLE

54.

Which SQL function combines the values of two columns?

a)

ADD()

b)

MERGE()

c)

JOIN()

d)

CONCAT()

55.

Which SQL function is used to find the average value of a numeric column?

a)

SUM()

b)

MEDIAN()

c)

MEAN()

d)

AVG()