Add new rows into a table.
The INSERT statement adds one or more new rows of data into a table. You can insert values explicitly by listing column names and corresponding values, or you can insert data from another table using a subquery. If column names are omitted, values must be provided for every column in the table in the order they are defined. INSERT is one of the fundamental data manipulation language (DML) statements in SQL.
| Name | Description | Optional |
|---|---|---|
table |
The name of the table to insert data into. | No |
columns |
The columns to insert values into. If omitted, values for all columns must be provided. | Yes |
values |
The values to insert, specified after the VALUES keyword. | No |
INSERT INTO users (name, age) VALUES ('Alice', 30);
INSERT INTO logs (message) VALUES ('User logged in');