INSERT statement
The INSERT statement is a fundamental SQL command used to add new rows of data into a table.
The INSERT statement is a fundamental SQL command used to add new rows of data into a table. In DuckDB, this statement allows you to populate tables with values, either one row at a time or in bulk. The basic syntax involves specifying the target table and the values to be inserted. For example:
Copy code
INSERT INTO employees (first_name, last_name, hire_date)
VALUES ('John', 'Doe', '2023-01-15');
Related terms
The CREATE TABLE statement is a fundamental SQL command that defines a new table in a database, specifying its structure including column names, data types,…
UPSERT →UPSERT is a database operation that inserts a new row or updates an existing one if a matching row already exists, typically expressed with an ON CONFLICT clause.
UPDATE statement →The UPDATE statement modifies existing rows in a table, setting one or more column values for rows that match an optional WHERE condition.
MERGE statement →MERGE INTO is a SQL statement that inserts, updates, or deletes rows in a target table based on how they match rows from a source table, in a single atomic operation.
ALTER TABLE statement →The ALTER TABLE statement allows you to modify the structure of an existing database table without having to recreate it from scratch.
DEFAULT value →A DEFAULT value is a value a database column automatically takes on when an INSERT statement doesn't explicitly specify a value for it.
FAQS
INSERT adds new rows to a table. In DuckDB you can insert one row, many rows at once, or the results of a query.
Use INSERT INTO table (cols) VALUES (...) for explicit values, or INSERT INTO table SELECT ... to insert from a query result.
A variant that updates an existing row when an insert would cause a conflict (for example on a primary key) instead of failing—useful for upserts.
