Inserting and updating data with REPLACE

Add data to the table using REPLACE 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. REPLACE 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. 12,
  14. "Test Episode !!!",
  15. CAST(Date("2018-08-27") AS Uint64)
  16. )
  17. ;
  18. -- COMMIT is called so that the next SELECT operation
  19. -- can see the changes made by the previous transaction.
  20. COMMIT;
  21. -- View result:
  22. SELECT * FROM episodes WHERE series_id = 2 AND season_id = 5;
  23. COMMIT;

Inserting and updating data with REPLACE - 图1