SQL Flashcards

functions and tags

1
Q

What does the SELECT statement do in SQL?

A

The SELECT statement retrieves data from a database.

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

What is the purpose of the WHERE clause?

A

The WHERE clause filters records that meet specified conditions.

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

How do you use the INSERT INTO statement?

A

The INSERT INTO statement is used to add new records to a table.

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

What does the UPDATE statement do?

A

The UPDATE statement modifies existing records in a table.

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

What is the function of the DELETE statement?

A

The DELETE statement removes existing records from a table.

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

Explain the JOIN clause.

A

The JOIN clause 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 the INNER JOIN do?

A

The INNER JOIN returns records that have matching values in both tables.

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

What is a LEFT JOIN?

A

The LEFT JOIN returns all records from the left table and matched records from the right table.

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

Describe the RIGHT JOIN

A

The RIGHT JOIN returns all records from the right table and matched records from the left table.

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

What is a FULL OUTER JOIN?

A

The FULL OUTER JOIN returns all records when there is a match in either left or right table

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

What is the purpose of the GROUP BY clause?

A

The GROUP BY clause groups rows that have the same values in specified columns.

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

How does the HAVING clause work?

A

The HAVING clause filters groups based on specified conditions

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

What does the ORDER BY clause do?

A

The ORDER BY clause sorts the result set in ascending or descending order.

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

Explain the use of the LIMIT clause.

A

The LIMIT clause restricts the number of rows returned by a query.

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

What does the DISTINCT keyword do?

A

The DISTINCT keyword removes duplicate records from the result set.

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

What is the function of the COUNT() function?

A

The COUNT() function returns the number of rows that match a specified criterion.

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

How is the SUM() function used?

A

The SUM() function calculates the total sum of a numeric column.

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

What does the AVG() function do?

A

The AVG() function calculates the average value of a numeric column.

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

Describe the MIN() function.

A

The MIN() function returns the smallest value in a specified column.

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

What is the purpose of the MAX() function?

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

What does the LIKE operator do?

A

The LIKE operator is used to search for a specified pattern in a column.

22
Q

How is the IN operator used?

A

The IN operator allows specifying multiple values in a WHERE clause.

23
Q

Explain the BETWEEN operator.

A

The BETWEEN operator selects values within a given range.

24
Q

What does the IS NULL condition do?

A

The IS NULL condition tests for empty values.

25
Q

Describe the UNION operator.

A

The UNION operator combines the result sets of two or more SELECT statements.

26
Q

What is the function of the EXCEPT operator?

A

The EXCEPT operator returns distinct rows from the left query that are not in the right query.

27
Q

How does the INTERSECT operator work?

A

The INTERSECT operator returns the common records from two SELECT statements.

28
Q

Explain the CREATE TABLE statement.

A

The CREATE TABLE statement is used to create a new table in the database.

29
Q

What does the DROP TABLE statement do?

A

The DROP TABLE statement deletes a table and its data from the database.

30
Q

Describe the ALTER TABLE statement.

A

The ALTER TABLE statement modifies an existing table structure, such as adding or dropping columns.

31
Q

What is a PRIMARY KEY?

A

A PRIMARY KEY uniquely identifies each record in a table.

32
Q

Explain the FOREIGN KEY constraint.

A

A FOREIGN KEY is a key used to link two tables together.

33
Q

What is the purpose of the INDEX statement?

A

The INDEX statement creates an index (search key) for faster retrieval of records

34
Q

Describe the AUTO_INCREMENT attribute.

A

The AUTO_INCREMENT attribute automatically generates a unique number when a new record is inserted

35
Q

What does the DEFAULT constraint do?

A

The DEFAULT constraint provides a default value for a column when no value is specified.

36
Q

How is the CHECK constraint used?

A

The CHECK constraint limits the value range that can be placed in a column.

37
Q

Explain the CASE statement.

A

The CASE statement allows for conditional logic within a SQL query.

38
Q

What does the COALESCE function do?

A

The COALESCE function returns the first non-null value in a list.

39
Q

Describe the NULLIF function.

A

The NULLIF function returns NULL if the two arguments are equal.

40
Q

What is the purpose of the CAST function?

A

The CAST function converts a value from one data type to another.

41
Q

How is the CONVERT function used?

A

The CONVERT function converts a value from one data type to another, similar to CAST.

42
Q

Explain the TRUNCATE TABLE statement.

A

The TRUNCATE TABLE statement deletes all rows in a table without logging individual row deletions.

43
Q

What does the RENAME statement do?

A

The RENAME statement changes the name of a table or a database object.

44
Q

Describe the MERGE statement.

A

The MERGE statement performs INSERT, UPDATE, or DELETE operations on a target table based on the results of a join with a source table.

45
Q

What is a VIEW in SQL?

A

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

46
Q

Explain the CREATE VIEW statement.

A

The CREATE VIEW statement creates a view from a SQL query.

47
Q

What does the DROP VIEW statement do?

A

The DROP VIEW statement deletes a view from the database.

48
Q

Describe the ALTER VIEW statement.

A

The ALTER VIEW statement modifies an existing view.

49
Q

What is the EXPLAIN statement used for?

A

The EXPLAIN statement provides information about how SQL statements are executed, useful for performance tuning.

50
Q

How is the DESCRIBE statement used?

A

The DESCRIBE statement provides information about the structure of a table, such as column names and data types.