sql-update-insert-delete Flashcards

1
Q

How do you add a row to a SQL table?

A

INSERT INTO “table_name” (“col1”, “col2”)
VALUES (“col1val”, “col2val”)

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

What is a tuple?

A

A tuple is a batch of values surrounded by parenthesis

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

Using multiple comma separated tuples after the VALUES keyword

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

Use RETURNING * or RETURNING “col_names”

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 “table_name”
SET “col1” = 100,
“col2” = 40
WHERE “col” = 10;

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

If you dont include a WHERE clause then the entire column will become that value.

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 “table_name”
WHERE “col1” = “col1val”

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 “table_name”

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