Inserting and updating data with UPSERT

Add data to the table using UPSERT INTO:

Note

We assume that you already created tables in step Creating a table and populated them with data in step Adding data to a table.

  1. UPSERT INTO episodes
  2. (
  3. series_id,
  4. season_id,
  5. episode_id,
  6. title,
  7. air_date
  8. )
  9. VALUES
  10. (
  11. 2,
  12. 5,
  13. 13,
  14. "Test Episode",
  15. CAST(Date("2018-08-27") AS Uint64)
  16. )
  17. ;
  18. COMMIT;
  19. -- View result:
  20. SELECT * FROM episodes WHERE series_id = 2 AND season_id = 5;
  21. COMMIT;

Inserting and updating data with UPSERT - 图1