SQL Flashcards

1
Q

How do you add a row to a SQL table?

A

Insert into ‘TableName’, (Columns), (Values)

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

What is a tuple?

A

a group of things be inserted into a table

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

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

A

You just add more values and separate with commas

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

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

A

Add return ‘col1’, ‘col2’ or * for all

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

How do you update rows in a database table?

A

update ‘tableName’ set ‘column you want to change’ = ‘new value’

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

How do you update rows in a database table?

A

update ‘tableName’ set ‘column you want to change’ = ‘new value’

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

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

A

So you only change a specific row

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

How do you delete rows from a database table?

A

delete from ‘tableName’ where ‘row’

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

How do you accidentally delete all rows from a table?

A

delete from ‘tableName’

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

What is a foreign key?

A

a column of data that points to a unique value in another table

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

How do you join two SQL tables?

A

join ‘tableName’ using ‘valueName’

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

How do you temporarily rename columns or tables in a SQL statement?

A

as

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

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

A

It is a query based language

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

How do you retrieve specific columns from a database table?

A

select then column names

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

How do you filter rows based on some specific criteria?

A

where clause

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

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

A

<, >, <=, >=

16
Q

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

A

limit

17
Q

How do you retrieve all columns from a database table?

A

*

18
Q

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

A

order by, desc, asc

19
Q

What are some examples of aggregate functions?

A

avg(‘columnName’), sum(‘columName’) as new name