sql-insert Flashcards
How do you add a row to a SQL table?
INSERT INTO table_name (column1, column2, column3, …)
VALUES (value1, value2, value3, …);
What is a tuple?
A tuple is a collection of ordered, immutable values of different data types.
How do you add multiple rows to a SQL table at once?
“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 do you get back the row being inserted into a table without a separate select statement?
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 *;