wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

SQL Multiple Choice Worksheet

Total questions: 100

Worksheet time: 50mins

Name
Class
Date
1.

SQL stands for:

a)

Simple Query Language

b)

Structured Query Language

c)

Strong Question Logic

d)

Storage Query Language

2.

Which keyword retrieves data from a table?

a)

GET

b)

READ

c)

SELECT

d)

FETCH

3.

Select all columns from employees:

a)

SELECT employees;

b)

SELECT ALL FROM employees;

c)

SELECT * FROM employees;

d)

SHOW employees;

4.

Which keyword removes duplicates?

a)

UNIQUE

b)

DISTINCT

c)

SEPARATE

d)

CLEAR

5.

Which clause filters rows?

a)

ORDER BY

b)

GROUP BY

c)

WHERE

d)

SET

6.

Choose the correct syntax for sorting ascending:

a)

ORDER UP col;

b)

ORDER BY col ASC;

c)

SORT col;

d)

ASCENDING col;

7.

Which operator searches patterns?

a)

LIKE

b)

MATCH

c)

SEARCH

d)

FIND

8.

Which operator selects within a range?

a)

RANGE

b)

LIMIT

c)

BETWEEN

9.

Which operator checks membership in a list?

a)

HAS

b)

LIST

c)

AMONG

d)

IN

10.

Which function counts rows?

a)

SUM()

b)

AVG()

c)

TOTAL()

d)

COUNT()

11.

Which keyword adds new rows?

a)

ADD

b)

INSERT

c)

UPDATE

d)

INCLUDE

12.

Which keyword modifies existing rows?

a)

CHANGE

b)

REWRITE

c)

UPDATE

d)

MODIFY

13.

Which keyword deletes rows?

a)

DELETE

b)

REMOVE

c)

CUT

d)

DROP

14.

Which clause groups rows?

a)

ORDER BY

b)

GROUP BY

c)

HAVING

d)

JOIN

15.

HAVING is used with:

a)

SELECT

b)

DELETE

c)

GROUP BY

d)

INSERT

16.

To get average salary:

a)

AVG(salary)

b)

MEAN(salary)

c)

AVERAGE salary

d)

COUNT(salary)

17.

Which is an aggregate function?

a)

SUBSTR()

b)

COUNT()

c)

REPLACE()

d)

TRIM()

18.

LIMIT is used to:

a)

Restrict number of rows

b)

Rename column

c)

Add constraint

d)

Set default value

19.

What does IS NULL check?

a)

If value is empty string

b)

If value is zero

c)

If value is NULL

d)

If value is missing column

20.

Which returns unique departments?

a)

SELECT ONLY dept FROM emp;

b)

SELECT UNIQUE dept FROM emp;

c)

SELECT DISTINCT dept FROM emp;

d)

SELECT dept UNIQUE;

21.

Default join type:

a)

CROSS

b)

FULL

c)

INNER

d)

LEFT

22.

Join two tables:

a)

SELECT * MERGE a b;

b)

SELECT * FROM a JOIN b ON condition;

c)

SELECT a WITH b;

d)

SELECT * COMBINE a b;

23.

Which join returns all rows from left table?

a)

RIGHT

b)

INNER

c)

LEFT

d)

FULL

24.

Join returning all rows from both tables:

(a)  

25.

To get unmatched left rows:

a)

RIGHT JOIN

b)

LEFT JOIN + WHERE right.id IS NULL

c)

INNER JOIN

d)

FULL JOIN

26.

Self join means:

a)

A. A table joins with itself

b)

B. A user joins two tables

c)

C. Joining identical schemas

d)

D. Using CROSS JOIN

27.

CROSS JOIN produces:

a)

Filtered rows

b)

Cartesian product

c)

Full outer join

d)

Unique rows

28.

Which join uses matching column names automatically?

a)

INNER

b)

NATURAL

c)

LEFT

d)

CROSS

29.

UNION does what?

a)

Joins columns

b)

Combines rows without duplicates

c)

Combines rows with duplicates

d)

Merges tables physically

30.

UNION ALL does what?

a)

Removes duplicates

b)

Adds constraints

c)

Keeps duplicates

d)

Sorts results

31.

Which join returns only matched rows?

a)

FULL

b)

INNER

c)

LEFT

d)

RIGHT

32.

Which clause is required for join?

a)

A. ON

b)

B. USE

c)

C. MAP

33.

Non-equi join uses:

a)

=

b)

LIKE

c)

BETWEEN / < / >

d)

AND

34.

Which join can produce the largest number of rows?

a)

INNER

b)

CROSS

c)

LEFT

d)

RIGHT

35.

Which join returns unmatched rows from right table?

a)

LEFT

b)

INNER

c)

RIGHT

d)

FULL

36.

NATURAL JOIN matches columns by:

a)

Length

b)

Position

c)

Name

d)

Data type

37.

Two queries merged into one result set:

a)

EXCEPT

b)

MERGE

c)

UNION

d)

ADD

38.

Which eliminates duplicates?

a)

UNION

b)

UNION ALL

c)

JOIN

d)

MERGE

39.

FULL JOIN missing row output:

a)

Only matched rows

b)

Unmatched + matched rows

c)

Only unmatched

d)

Only left rows

40.

Each join must specify:

a)

Data type

b)

Primary key

c)

Condition

d)

Constraints

41.

Creates a table:

a)

MAKE TABLE

b)

BUILD TABLE

c)

CREATE TABLE

d)

NEW TABLE

42.

Primary key must be:

a)

Unique & Not Null

b)

Unique only

c)

Not null only

d)

Random

43.

Foreign key refers to:

a)

A random column

b)

A view

c)

A primary key in another table

d)

A unique index

44.

Unique constraint allows:

a)

No duplicates

b)

Only NULL

c)

No NULL

d)

Unlimited values

45.

NOT NULL ensures:

a)

Column cannot be zero

b)

Column cannot be blank

c)

Column cannot be NULL

d)

Column must be unique

46.

CHECK constraint tests:

a)

Format

b)

A specific condition

c)

User privilege

d)

Index

47.

DELETE removes:

a)

Only table structure

b)

Rows

c)

Columns

d)

Primary key

48.

TRUNCATE removes:

a)

Table

b)

Indexed columns

c)

All rows quickly

49.

DROP TABLE removes:

a)

Rows only

b)

Columns only

c)

Entire table structure

d)

Indexes only

50.

ALTER TABLE is used to:

a)

Insert rows

b)

Modify table structure

c)

Select rows

d)

Delete records

51.

51. ADD COLUMN syntax:

a)

ALTER TABLE t ADD col datatype;

b)

ADD col datatype TO t;

c)

t ADD col;

d)

MODIFY t ADD col;

52.

Composite key is:

a)

A key from another table

b)

Multiple columns making a primary key

c)

A unique index

d)

A key with default value

53.

ON DELETE CASCADE does:

a)

Prevent delete

b)

Deletes parent only

c)

Deletes child rows automatically

d)

Ignores delete

54.

A schema is:

a)

A. A trigger

b)

B. A database user

c)

C. A collection of tables

d)

D. A stored procedure

55.

Which is DDL?

a)

INSERT

b)

UPDATE

c)

CREATE

d)

DELETE

56.

DML includes:

a)

DROP

b)

CREATE

c)

ALTER

d)

SELECT

57.

UNIQUE allows how many NULLs?

a)

None

b)

One

c)

Many (DB-dependent but usually many)

d)

Unlimited non-NULLs

58.

DEFAULT does what?

a)

Calculates new values

b)

Sets a fallback value

c)

Creates an index

d)

Creates a trigger

59.

Command to rename table (MySQL):

a)

RENAME TO

b)

CHANGE TABLE

c)

RENAME TABLE old TO new

d)

NEW TABLE NAME

60.

Command to delete a column:

a)

DELETE COLUMN col;

b)

ALTER TABLE t DROP COLUMN col;

c)

REMOVE col;

d)

DROP col;

61.

A subquery is:

a)

A comment

b)

A query inside another query

c)

A stored function

d)

A temporary table

62.

Subqueries can be used in:

a)

WHERE

b)

FROM

c)

SELECT

d)

All of the above

63.

Correlated subquery:

a)

Runs independently

b)

Refers to outer query

c)

Uses no tables

d)

Is always faster

64.

EXISTS returns:

a)

The count

b)

True/false

65.

ANY means:

a)

Compare with all values

b)

Compare with at least one value

c)

Compare with none

d)

Compare with two values

66.

ALL means:

a)

Compare with all values

b)

Compare with some values

c)

Compare with one value

d)

Always return true

67.

A derived table is:

a)

A. A temporary table

b)

B. A subquery in FROM

c)

C. A permanent table

d)

D. A view

68.

A view is:

a)

Actual stored data

b)

Virtual table

c)

Index

d)

Trigger

69.

Materialized view:

a)

Always empty

b)

Virtual only

c)

Stores physical data

d)

Cannot be queried

70.

2nd highest salary:

a)

MAX(salary)

b)

MIN(salary)

c)

ORDER BY salary LIMIT 2

d)

Using subquery

71.

Query to find duplicates uses:

a)

WHERE

b)

HAVING COUNT(*) > 1

c)

ORDER BY

d)

DISTINCT

72.

Subquery returning multiple rows is used with:

a)

=

b)

IN

c)

LIKE

73.

When subquery returns >1 row and = is used:

a)

Works fine

b)

Error

c)

Warning only

d)

Returns NULL

74.

DELETE duplicates keeping one:

a)

Impossible

b)

Using correlated query

c)

Using CROSS JOIN

d)

Using HAVING only

75.

A CTE begins with:

a)

BEGIN

b)

WITH

c)

DEFINE

d)

TEMP

76.

Recursive CTE is used for:

a)

Sorting

b)

Tree / hierarchy traversal

c)

Grouping

d)

Indexing

77.

Window functions use:

a)

OVER()

b)

UNDER()

c)

RANGE()

d)

ROWS() only

78.

Rank without gaps:

a)

ROW_NUMBER

b)

RANK

c)

DENSE_RANK

d)

LEAD

79.

Function to look at previous row:

a)

NEXT

b)

LAG

c)

LEAD

d)

BACK

80.

Running total uses:

a)

COUNT()

b)

SUM() OVER()

c)

TOTAL()

d)

ADD()

81.

Index improves:

a)

Storage size

b)

Speed of queries

c)

Table creation

d)

Triggers

82.

Index not useful on:

a)

Unique values

b)

Primary keys

c)

Low-cardinality columns

d)

Foreign keys

83.

Clustered index determines:

a)

Primary key

b)

Physical table order

c)

Logical view order

d)

Temporary sorting

84.

Non-clustered index stores:

a)

Table data itself

b)

Pointer to data

c)

Triggers

d)

Constraints

85.

ACID: A stands for

a)

Addition

b)

Atomicity

c)

Accessibility

d)

Action

86.

Transaction begins with:

a)

RUN

b)

BEGIN

c)

OPEN

d)

START ONLY

87.

COMMIT does what?

a)

Undo changes

b)

Save changes

c)

Lock table

d)

Close database

88.

ROLLBACK does:

a)

Save

b)

Undo

c)

Delete

89.

Deadlock is:

a)

Too many rows

b)

Two transactions waiting on each other

c)

Data corruption

d)

Missing indexes

90.

Foreign key ensures:

a)

Performance

b)

Referential integrity

c)

Faster SELECT

d)

Automatic indexing

91.

A trigger runs:

a)

Automatically on events

b)

Only manually

c)

On server restart

d)

Once per day

92.

Stored procedure is:

a)

Query history

b)

Saved SQL code

c)

Database schema

d)

Constraint

93.

COALESCE returns:

a)

Lowest value

b)

First non-NULL value

c)

Last row

d)

Largest value

94.

NULL means:

a)

Zero

b)

Empty string

c)

Unknown / missing

d)

False

95.

Which handles string matching?

a)

LIKE

b)

MATCH() only

c)

IN

d)

AS

96.

What does ORDER BY 1 mean?

a)

Order by first row

b)

Order by first column

c)

Order randomly

d)

Order by ID only

97.

Which removes whitespace?

a)

CUT

b)

TRIM

c)

DELETE

d)

CLEAN

98.

Which extracts substring?

a)

SUBSTR()

b)

CUT()

c)

TAKE()

d)

MID only

99.

Which returns current date?

a)

NOW()

b)

DATE()

c)

TODAY()

d)

TIME()

100.

Replace NULL salary with 0:

a)

IFNULL(salary)

b)

COALESCE(salary, 0)

c)

NULL(salary, 0)

d)

REPLACE(salary)