Tools
Update keys with SQL
Change Redis and Valkey key names, scalar values, TTLs, and collection members with Varc SQL UPDATE.
SQL Query can apply an UPDATE directly from the editor. The same bounded discovery and expression engine used by SELECT chooses rows, evaluates assignments, and reports progress.
UPDATE redis
SET value = CAST(value AS INTEGER) + 1,
ttl_ms = 60000
WHERE key = 'counter:visits'
RETURNING key, type, ttl_ms, value
LIMIT 1;
Choose Run or press Mod+Enter. Varc prepares the statement and completes read-only discovery, evaluation, and any required Cluster same-slot preflight before it asks you to approve the write phase. The approval is single-use and bound to that exact tab, source revision, prepared run, workspace incarnation, topology fact, and mutation plan. There is no implicit key restriction or automatic LIMIT, so write the predicate and bound that match the change you intend.
The approval states the exact matched-row count when known, the categories being changed, that each row is atomic, and that the statement as a whole is not transactional. Changing the source, reconnecting, replacing topology, closing the tab or tool, or starting a new run invalidates it.
Mutable columns
| Column | Accepted assignment | Effect |
|---|---|---|
key |
Text or binary scalar | Renames or relocates the exact binary-safe key. |
value |
Non-NULL Boolean, number, text, binary, or mutation function | Replaces a string value or applies a type-aware collection mutation. |
ttl_ms |
Integer or NULL | Sets a relative millisecond TTL, persists the key, or expires it now. |
type and redis_type are derived from the stored value and cannot be assigned. A target column can appear only once. Every assignment is evaluated from the original row, so one assignment never observes another assignment from the same SET clause.
Scalar Boolean and numeric values are stored using their text representation. A scalar value assignment requires a string key; collection mutation functions preserve the collection’s existing Redis type.
Rename a key
UPDATE redis
SET key = 'account:42:profile'
WHERE key = 'user:42'
RETURNING key, type, ttl_ms;
Varc never overwrites an existing destination key. A collision stops the statement and leaves both the source and destination unchanged. RETURNING rows contain the final key name, and activating one opens that exact key in the value viewer.
For Redis Cluster, a same-slot rename is part of the row’s atomic commit. Before the first write, Varc computes every affected destination and proves that every source/destination pair is in the same slot. Any cross-slot pair, indeterminate destination, or incomplete preflight rejects the whole statement with zero writes. There is no override or cross-slot relocation path.
Change or remove a TTL
UPDATE redis
SET ttl_ms = NULL
WHERE key LIKE 'session:%'
LIMIT 100;
Assigned ttl_ms |
Result |
|---|---|
| Positive integer | Set that relative lifetime in milliseconds. |
NULL |
Remove the expiry and persist the key. |
| Zero or negative | Expire the key immediately. |
An expression can calculate the new TTL from the original value, for example SET ttl_ms = ttl_ms + 30000 for keys that already have an expiry.
Mutate a collection
Collection functions are valid only as the top-level right-hand side of SET value = ..., and their first argument must be the bare value column:
UPDATE redis
SET value = HASH_SET(value, 'status', 'active', 'source', 'import')
WHERE key LIKE 'user:%' AND type = 'hash'
RETURNING key, type, HASH_GET(value, 'status') AS status
LIMIT 500;
Hashes, lists, sets, sorted sets, streams, and RedisJSON each have dedicated mutation functions. Wrong-type operations and unavailable server capabilities stop the statement; Varc does not recreate the key as a different type. See the SQL function reference for every signature.
Results and errors
Without RETURNING, the results pane reports the number of keys updated. With RETURNING, it publishes ordinary typed SQL rows after each key commits.
An UPDATE is atomic for one key, not across the whole statement. Varc stops according to the statement failure policy and reports applied, conflicted, rejected, unknown, and not-attempted outcomes truthfully. Earlier applied changes remain in Redis; there is no statement-wide rollback. LIMIT counts selected update attempts in traversal order.
A lost reply or other possibly-dispatched write is never retried blindly. Varc uses safe exact reads when an outcome can be proven; otherwise it retains an explicit Unknown outcome state and does not present Run Again as routine recovery.
Broad discovery and mutation use bounded segments. When a safe checkpoint is reached, choose Continue to resume with the retained position and committed-row count. See Results and limits.
Explain before running
EXPLAIN UPDATE redis
SET ttl_ms = 300000
WHERE key LIKE 'cache:%'
LIMIT 1000;
EXPLAIN UPDATE returns a sanitized semantic plan and performs no Redis I/O. It describes discovery, reads, same-slot requirements, row-at-a-time execution, and qualitative impact without exposing commands, arguments, literals, endpoints, topology identifiers, or implementation details.
The SQL language reference lists the exact grammar and unsupported UPDATE extensions.