sql Flashcards

1
Q

How do you retrieve specific columns from a database table?

A

use select and put the column name in the double quotes and put the key word from.

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

How do you filter rows based on some specific criteria?

A

use where clause

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

What are the benefits of formatting your SQL?

A

readible

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
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
5
Q

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

A

limit

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

How do you retrieve all columns from a database table?

A

asterisk

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

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

A

order by clause

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

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

A

Sql is a declarative language. JavaScript is imperative language.

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

How do you add a row to a SQL table?

A

insert into “Table Name”

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

What is a tuple?

A

a list of values

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

How do you add multiple rows to a SQL table at once?

A

specifying more than one tuple of values, separated by commas.

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

How do you get back the row being inserted into a table without a separate select statement?

A

returning clause (returning *)

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

How do you update rows in a database table?

A

update “products”

set “price” = 100;

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

Why is it important to include a where clause in your update statements?

A

You may update many rows if you did not target specific rows.

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

How do you delete rows from a database table?

A

delete from “products”

where “productId” = 24

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

How do you accidentally delete all rows from a table?

A

You did not include a where clause.