sql-insert Flashcards

1
Q

How do you add a row to a SQL table?

A

INSERT INTO table_name (column1, column2, column3, …)
VALUES (value1, value2, value3, …);

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 collection of ordered, immutable values of different data types.

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

“INSERT INTO” statement with multiple value sets:

scss
Copy code
INSERT INTO table_name (column1, column2, column3, …)
VALUES
(value1_1, value1_2, value1_3, …),
(value2_1, value2_2, value2_3, …),
…;

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

To retrieve the inserted row without a separate SELECT statement, use the “RETURNING” clause in the “INSERT INTO” statement:
INSERT INTO table_name (column1, column2, column3, …)
VALUES (value1, value2, value3, …)
RETURNING *;

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