Overview
TheUPDATE mutation is used to modify the existing records in a table. This support has limitations:
- Only one data mutation (DELETE or UPDATE) at given moment is possible, trying to run another one will result in failure.
- Data mutations rewrite all files containing the data from the UPDATE/DELETE condition. Please note that running
DELETE from tablewithout any condition is possible, but it will be much slower than justDROP TABLE table. - The syntax is simplified in comparison to Postgres. For example, the
SET column=<value>operation doesn’t support sub-SELECT as the value, also theWHEREclause cannot contain sub-SELECT.
Feature Update: Initial Release.
This marks the initial release of our new Mutation feature, providing you with the ability to update data. The Mutations involve rewriting entire files which take several minutes and could generate infrastructure costs. We are aiming to enhance and optimize this feature in future updates!
This marks the initial release of our new Mutation feature, providing you with the ability to update data. The Mutations involve rewriting entire files which take several minutes and could generate infrastructure costs. We are aiming to enhance and optimize this feature in future updates!
Syntax
The syntax forUPDATE mutation is as follows:
table: The name of the table you want to update.column1, column2: The columns that you wish to update.expression1, expression2: The new values to assign to column1, column2, and so on. Each column is set to its corresponding expression.WHERE conditions(Optional): The conditions that must be met for the update to execute. If no conditions are provided, all table records will be updated.
Examples
Let’s create a sample table called tasks:Case #1: Update a Single Column
- In this case, we want to update the
statuscolumn to “completed” for the record wheretask_idis 1001.
- The output below shows that the update was successful.
- Check the updated table by running the
SELECTquery below:
- The
UPDATEmutation updates the status to “completed” for the task with ID 1001.
Case #2: Update Multiple Columns
- Let’s assume we want to update the
task_nameandstatuscolumns for the record wheretask_idis 1002.
- The output below shows that the update was successful.
- Check the updated table by running the
SELECTquery below:
- Here, the task name and status columns are updated for the task with ID 1002.