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.
INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);
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.
INSERT INTO customers SELECT * FROM old_customers WHERE city = 'Los Angeles'
INSERT INTO customers DEFAULT VALUES
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.