Inserts data into a database table.

Syntax

Flow chart showing the syntax of the INSERT keyword

Examples

  1. INSERT INTO trades
  2. VALUES(
  3. to_timestamp('2019-10-17T00:00:00', 'yyyy-MM-ddTHH:mm:ss'),
  4. 'AAPL',
  5. 255,
  6. 123.33,
  7. 'B');
  1. INSERT INTO trades (timestamp, symbol, quantity, price, side)
  2. VALUES(
  3. to_timestamp('2019-10-17T00:00:00', 'yyyy-MM-ddTHH:mm:ss'),
  4. 'AAPL',
  5. 255,
  6. 123.33,
  7. 'B');

:::note

Columns can be omitted during INSERT in which case value will be NULL

:::

  1. INSERT INTO trades (timestamp, symbol, price)
  2. VALUES(to_timestamp('2019-10-17T00:00:00', 'yyyy-MM-ddTHH:mm:ss'),'AAPL','B');

Inserting query results

  1. INSERT INTO confirmed_trades
  2. SELECT timestamp, instrument, quantity, price, side
  3. FROM unconfirmed_trades
  4. WHERE trade_id = '47219345234'
  5. ;

:::note

This method allows you to insert several rows at once (as many as your query returns).

:::