Sql Statements Flashcards

(28 cards)

1
Q

Define SELECT statement.

A

It retrieves data from one or more tables in a database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does WHERE clause do?

A

It filters records based on specified conditions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

True or false: INSERT statement adds new rows to a table.

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Fill in the blank: UPDATE modifies existing ______ in a table.

A

records

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the purpose of DELETE statement?

A

It removes rows from a table based on conditions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Define JOIN.

A

It combines rows from two or more tables based on a related column.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does GROUP BY do?

A

It groups rows sharing a property so aggregate functions can be applied.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

True or false: ORDER BY sorts the result set.

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Fill in the blank: HAVING is used to filter records after ______.

A

aggregation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is an alias in SQL?

A

A temporary name for a table or column for easier reference.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Define PRIMARY KEY.

A

A unique identifier for each record in a table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What does FOREIGN KEY enforce?

A

Referential integrity between two related tables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

True or false: DISTINCT removes duplicate records from results.

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Fill in the blank: COUNT() function returns the number of ______.

A

rows

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the purpose of LIMIT clause?

A

It restricts the number of rows returned in a query.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Define VIEW in SQL.

A

A virtual table based on the result set of a query.

17
Q

What does UNION do?

A

It combines the results of two or more SELECT statements.

18
Q

True or false: NULL represents a value in SQL.

A

FALSE

NULL indicates the absence of a value.

19
Q

Fill in the blank: CASE statement provides ______ logic in SQL.

20
Q

What is the purpose of INDEX?

A

It improves the speed of data retrieval operations on a database table.

21
Q

Define TRIGGER.

A

A set of instructions that automatically executes in response to certain events on a table.

22
Q

What does ROLLBACK do?

A

It undoes changes made in the current transaction.

23
Q

True or false: COMMIT saves all changes made in a transaction.

24
Q

Fill in the blank: ALTER TABLE modifies the structure of an existing ______.

25
What is a **subquery**?
A query nested inside another SQL query.
26
Define **stored procedure**.
A set of SQL statements that can be stored and executed as a unit.
27
What does **EXPLAIN** do?
It provides information about how SQL statements are executed.
28
What does a * do in SQL?