Use INSERT INTO to append rows to an existing table in a writable connected data source. The examples use the PostgreSQL tables from 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.

INSERT INTO
  my_postgres.public.order_counts (customer_id, order_count)
VALUES
  (101, 3),
  (102, 5);
#
rows_written
12

​
Insert query results

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

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
11

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