INSERT INTO
BrandonDusch580 total contributions
Published Jun 26, 2021Updated Jul 13, 2022
Contribute to Docs
The INSERT INTO
command creates and places new rows into a table.
Syntax
INSERT INTO table_name
VALUES (value1, value2, ...);
Multiple rows can be inserted by adding additional sets to the VALUES
clause:
INSERT INTO table_name
VALUES
(value1, value2, ...),
(value1, value2, ...);
To add values corresponding to only specific columns, thereby leaving the rest of the row as default values, specify them alongside the table name:
INSERT INTO table_name (column1, column2, ...)
VALUES (value1, value2, ...);
Default values can also be added using the DEFAULT
keyword for the relevant column value:
INSERT INTO table_name
VALUES (value1, DEFAULT, value3, ...);
Example
The given query adds a new student to a students
table, providing values for first_name
, last_name
, and enrollment_date
, thereby inserting default values for all other columns:
INSERT INTO students (first_name, last_name, enrollment_date)VALUES ('Jeremy', 'Barbosa', '2016-09-01');
All contributors
- BrandonDusch580 total contributions
- christian.dinh2476 total contributions
- Anonymous contributorAnonymous contributor3071 total contributions
- JeremyBarbosa18 total contributions
- BrandonDusch
- christian.dinh
- Anonymous contributor
- JeremyBarbosa
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.