Logo icon
    • Contents
    • Quick start
    • Concepts
    • For DevOps
    • For Developers
      • Getting started
      • YQL tutorial
        • Creating a table
        • Adding data to a table
        • Selecting data from all columns
        • Selecting data from specific columns
        • Sorting and filtering
        • Data aggregation
        • Additional selection criteria
        • Joining tables with JOIN
        • Inserting and updating data with REPLACE
        • Inserting and updating data with UPSERT
        • Inserting data with INSERT
        • Updating data with UPDATE
        • Deleting data
        • Adding and deleting columns
        • Deleting a table
      • Example applications
      • Primary keys
      • Secondary indexes
      • Query plans optimization
      • Batch upload
      • Paging
      • Timeouts
      • System views
      • Change Data Capture
      • Terraform
      • Custom attributes
    • For Security Engineers
    • For Contributors
    • Reference
    • Recipes
    • Troubleshooting
    • Questions and answers
    • Downloads
    1. For Developers
    2. YQL tutorial
    3. Inserting and updating data with UPSERT

    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.

    UPSERT INTO episodes
    (
        series_id,
        season_id,
        episode_id,
        title,
        air_date
    )
    VALUES
    (
        2,
        5,
        13,
        "Test Episode",
        CAST(Date("2018-08-27") AS Uint64)
    )
    ;
    
    COMMIT;
    
    -- View result:
    SELECT * FROM episodes WHERE series_id = 2 AND season_id = 5;
    
    COMMIT;
    

    Was the article helpful?

    Previous
    Inserting and updating data with REPLACE
    Next
    Inserting data with INSERT