SQL INSERT Statement

The SQL INSERT statement is used to add new records to a database table. It is an important part of any SQL query and is commonly used to populate a database with data. INSERT is a powerful operation and should be used with caution, as it can permanently add data to a database.

Syntax

INSERT INTO table_name (column1, column2, ...)
VALUES (value1, value2, ...);
    

Example

INSERT INTO customers (customer_id, first_name, last_name, city)
VALUES (123, 'John', 'Doe', 'New York');
    

This example inserts a new record into the "customers" table with the specified values for the customer ID, first name, last name, and city.

Options

There are many other options and clauses that can be used with the INSERT statement, such as ON DUPLICATE KEY UPDATE and RETURNING. You can learn more about these and other advanced topics in our SQL tutorials and references.