Basic Commands Flashcards

(33 cards)

1
Q

What does the SELECT command do in SQL?

A

Retrieves data from a database table.

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

What does the FROM clause specify in SQL?

A

The table or tables from which data will be retrieved.

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

What is the purpose of the WHERE clause?

A

Filters rows based on a specified condition.

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

What does the JOIN clause do?

A

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
5
Q

What is an INNER JOIN?

A

Returns rows that have matching values in both tables.

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

What is a LEFT JOIN?

A

Returns all rows from the left table and matching rows from the right table.

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

What is a RIGHT JOIN?

A

Returns all rows from the right table and matching rows from the left table.

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

What does GROUP BY do in SQL?

A

Groups rows that have the same values so aggregate functions can be applied.

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

What is the purpose of the HAVING clause?

A

Filters grouped results after aggregation.

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

What does ORDER BY do?

A

Sorts query results in ascending or descending order.

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

What does the LIMIT clause do?

A

Restricts the number of rows returned by a query.

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

What does DISTINCT do in SQL?

A

Removes duplicate rows from the result set.

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

What does the INSERT command do?

A

Adds new rows to a table.

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

What does the UPDATE command do?

A

Modifies existing rows in a table.

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

What does the DELETE command do?

A

Removes rows from a table.

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

What is MERGE or UPSERT used for?

A

Inserts a new row or updates an existing row depending on whether a match exists.

17
Q

What does CREATE TABLE do?

A

Creates a new table in the database.

18
Q

What does ALTER TABLE do?

A

Modifies the structure of an existing table.

19
Q

What does DROP TABLE do?

A

Permanently deletes a table and its data.

20
Q

What does TRUNCATE TABLE do?

A

Quickly removes all rows from a table without deleting the table itself.

21
Q

What does CREATE INDEX do?

A

Creates an index to improve query performance.

22
Q

What does DROP INDEX do?

A

Removes an index from a table.

23
Q

What does the CASE expression do in SQL?

A

Performs conditional logic similar to an if-then-else statement.

24
Q

What does COALESCE do in SQL?

A

Returns the first non-null value from a list of expressions.

25
What does CAST do in SQL?
Converts a value from one data type to another.
26
What does UNION do?
Combines results of two queries and removes duplicates.
27
What does UNION ALL do?
Combines results of two queries without removing duplicates.
28
What does BEGIN or START TRANSACTION do?
Starts a database transaction.
29
What does COMMIT do?
Saves all changes made during a transaction permanently.
30
What does ROLLBACK do?
Reverts changes made during a transaction.
31
What does SAVEPOINT do?
Creates a point within a transaction that you can roll back to.
32
What does the GRANT command do?
Gives a user permission to access or modify database objects.
33
What does the REVOKE command do?
Removes permissions previously granted to a user.