SQL DML - 50 MCQs

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/49

flashcard set

Earn XP

Description and Tags

Flashcards for SQL DML MCQs

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

50 Terms

1
New cards

SELECT

Retrieve data

2
New cards

What clause must follow the SELECT clause?

FROM

3
New cards

SELECT * FROM employees;

Selects all columns

4
New cards

DISTINCT keyword

Returns only unique values

5
New cards

Which keyword assigns an alias to a column?

AS

6
New cards

Which keyword is optional but recommended when using aliases?

AS

7
New cards

Which clause restricts the rows returned in a query?

WHERE

8
New cards

Which comparison operator means 'not equal'?

<> and !=

9
New cards

WHERE first_name LIKE 'S%'

First names that start with 'S'

10
New cards

Which character is used in LIKE to represent a single character?

_

11
New cards

What does IN check for?

A value in a list

12
New cards

What will IS NULL return?

All rows with NULL in the column

13
New cards

Which operator checks if a value lies within a specific range?

BETWEEN

14
New cards

Which of the following is a valid logical operator?

NOT, OR, AND

15
New cards

What is the result of AND if both conditions are TRUE?

TRUE

16
New cards

What does NOT do?

Reverses the condition

17
New cards

What is the first order of precedence in SQL evaluation?

Comparison operators

18
New cards

How can you override precedence in SQL?

Use parentheses

19
New cards

What is the default order for ORDER BY?

Ascending

20
New cards

Which clause is used to sort rows in SQL?

ORDER BY

21
New cards

Which symbol is used for multiplication in SQL?

*

22
New cards

Which has higher precedence: addition or multiplication?

Multiplication

23
New cards

Which operator is used to concatenate strings?

||

24
New cards

Which query shows full employee name and department number?

SELECT firstname || ' ' || lastname || ' works in department ' || department_id FROM employees;

25
New cards

SELECT table1.column1, table2.column2 FROM table1, table2 WHERE table1.id = table2.id;

Joins two tables

26
New cards

What is a table alias?

A temporary table name

27
New cards

Which JOIN returns only matched records from both tables?

INNER JOIN

28
New cards

Which JOIN returns all records from the left table?

LEFT JOIN

29
New cards

Which JOIN gives a Cartesian product?

CROSS JOIN

30
New cards

What is the result of FULL OUTER JOIN?

All matched and unmatched rows

31
New cards

Which statement adds new rows?

INSERT

32
New cards

What happens if you insert a row with a foreign key that doesn't exist?

Error

33
New cards

What is the correct syntax for inserting values?

INSERT INTO table (columns) VALUES (values);

34
New cards

What clause is optional in UPDATE but critical to target specific rows?

WHERE

35
New cards

What happens if you omit WHERE in UPDATE?

All rows updated

36
New cards

How do you delete all rows from a table?

DELETE FROM table;

37
New cards

What command can undo a DELETE (if not committed)?

ROLLBACK

38
New cards

What happens when a DELETE has no WHERE clause?

All rows deleted

39
New cards

What must you do before inserting a new department with a new location?

Insert into locations table first

40
New cards

How do you correct a wrongly inserted department name?

UPDATE

41
New cards

What does a SELF JOIN do?

Joins a table to itself

42
New cards

What does the CROSS JOIN result in?

Cartesian product

43
New cards

Which join displays customers even if they haven't placed orders?

LEFT JOIN

44
New cards

What is the purpose of using AS in a JOIN?

Assign aliases

45
New cards

SELECT A.name, B.name FROM A, B WHERE A.city = B.city, what type of join is this?

Equi-Join

46
New cards

Which command saves all changes made in a session?

COMMIT

47
New cards

What is needed to avoid invalid foreign key entries?

Existing referenced records

48
New cards

SELECT * FROM employees WHERE salary BETWEEN 3000 AND 6000;

Shows salaries from 3000 to 6000

49
New cards

What type of JOIN will always show nulls for unmatched rows on both sides?

FULL OUTER

50
New cards

What command permanently removes a table?

DROP