sql-select Flashcards

1
Q

What is SQL and how is it different from languages like JavaScript?

A
  • Structured Query Language (SQL) is the primary way of interacting with relational databases. It is a powerful way of retrieving, creating, and manipulating data in a relational database.
  • SQL is a declarative programming language, meaning you describe the results you want and the programming environment comes up with its plan for getting those result.
  • while JavaScript is an imperative programming language, meaning that you have to tell JavaScript what to do and how to do it.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you retrieve specific columns from a database table?

A

select keyword and followed by column name surrounded by double quotes

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

How do you filter rows based on some specific criteria?

A

where clause and followed by column name surrounded by double quotes , equal sign, and values wrapped in single quotes.

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

What are the benefits of formatting your SQL?

A

for consistent style and better readability.

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

What are four comparison operators that can be used in a where clause?

A

=, >,

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

How do you limit the number of rows returned in a result set?

A

limit clause followed by an integer number

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

How do you retrieve all columns from a database table?

A

select * (asterisk)

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

How do you control the sort order of a result set?

A

order by clause, followed by a column name in double quotes, the default sort order is ascending order, or you can add desc keyword to switch to descending order.

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