W3. SQL Comments Flashcards

1
Q

Q: What is the purpose of comments in SQL?

A

A: Comments explain sections of SQL statements or prevent execution of specific code parts.

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

Q: Are comments supported in Microsoft Access databases?

A

A: No, comments are not supported in Microsoft Access databases.

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

Q: How do you write a single-line comment in SQL?

A

A: Use –, followed by the comment text.

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

Q: Write a single-line comment to explain “Select all” before a SQL query.

A

– Select all:
SELECT * FROM Customers;

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

Q: How can you use a single-line comment to ignore part of a SQL statement?

A

A: Place – after the code you want to execute, e.g.,

SELECT * FROM Customers – WHERE City=’Berlin’;

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

Q: How do you write a multi-line comment in SQL?

A

A: Wrap the text with /* and */.

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

Q: Write a multi-line comment to describe a SQL query that selects all records from Customers.

A

/*
Select all the columns
of all the records
in the Customers table:
*/
SELECT * FROM Customers;

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

Q: How can you use multi-line comments to ignore multiple SQL statements?

A

A: Place /* before and */ after the statements, e.g.,

/*
SELECT * FROM Customers;
SELECT * FROM Products;
*/

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

Q: Write a query that uses a comment to ignore part of a line in a SELECT statement.

A

SELECT CustomerName, /City,/ Country FROM Customers;

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

Q: Write a query that uses a comment to ignore part of a condition in a WHERE clause.

A

SELECT * FROM Customers
WHERE (CustomerName LIKE ‘L%’
OR CustomerName LIKE ‘R%’ /* OR CustomerName LIKE ‘S%’
OR CustomerName LIKE ‘T%’ */
OR CustomerName LIKE ‘W%’)
AND Country=’USA’
ORDER BY CustomerName;

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