# INSERT INTO
source: https://docs.chalk.ai/docs/chalksql/statements/insert-into

## Append literal rows or query results to an existing table in a connected SQL data source.

Use `INSERT INTO` to append rows to an existing table in a writable
[connected data source](/docs/chalksql/catalog/connected-data). The examples
use the PostgreSQL tables from [`CREATE TABLE`](/docs/chalksql/statements/create-table).
They require the Chalk permission `chalk:datasource:write:my_postgres` and
database credentials with insert privileges on the destination table.

### Insert literal rows

Append literal rows with `VALUES`, or use a `SELECT` as the input. Match the
input values to the destination columns by position. With an explicit column
list, omitted columns use the database's defaults. Without a list, supply
values in destination column order.

```sql
INSERT INTO my_postgres.public.order_counts (customer_id, order_count)
VALUES (101, 3), (102, 5);
```

| rows_written |
| ------------ |
| 2            |

### Insert query results

Use one output column per destination column in the same order.

```sql
INSERT INTO my_postgres.public.order_counts (customer_id, order_count)
SELECT customer_id, order_count
FROM my_postgres.public.repeat_customers
WHERE customer_id > 102;
```

| rows_written |
| ------------ |
| 1            |

Run inserts synchronously. The statement returns a `rows_written` column.
Chalk SQL rejects `INSERT` clauses such as `BY NAME`, `ON CONFLICT`, and
`RETURNING`.





