Update data with full WHERE/DELETE/INSERT semantics.
fluree update [LEDGER] [DATA] [OPTIONS]| Arguments | Behavior |
|---|---|
| (none) | Active ledger; provide data via -e, -f, or stdin |
<arg> |
Auto-detected: if it looks like data (JSON or SPARQL UPDATE), uses it inline with the active ledger; if it's an existing file, reads from it; otherwise treats it as a ledger name |
<ledger> <data> |
Specified ledger + inline data |
| Option | Description |
|---|---|
-l, --ledger <LEDGER> |
Ledger name (defaults to active ledger); explicit alternative to the positional ledger argument |
-e, --expr <EXPR> |
Inline data expression (alternative to positional) |
-f, --file <FILE> |
Read data from a file |
-m, --message <MSG> |
Commit message |
--format <FORMAT> |
Data format: jsonld, sparql, or cypher (auto-detected if omitted) |
--remote <NAME> |
Execute against a remote server (by remote name) |
--direct |
Bypass auto-routing through a local server (global flag; see note on SPARQL UPDATE below) |
Executes a WHERE/DELETE/INSERT transaction against a ledger. Unlike insert (which only adds data) and upsert (which replaces by subject+predicate), update supports the full WHERE/DELETE/INSERT pattern, enabling:
- Conditional deletes: delete triples matching a WHERE pattern
- Conditional updates: delete old values and insert new ones based on WHERE matches
- Computed updates: use variables from WHERE to derive new values via
bind - Delete-only operations: WHERE + DELETE without INSERT
- Insert-only operations: equivalent to
insertbut using the update command
- JSON-LD (default): transaction body with
where,delete, and/orinsertkeys - SPARQL UPDATE: standard
INSERT DATA,DELETE DATA,DELETE/INSERT WHEREsyntax - Cypher: openCypher writes (
CREATE/MERGE/SET/REMOVE/DELETE). Force with--format cypher, a.cypher/.cyp/.cqlfile, or a{"cypher": "..."}envelope. See the Cypher reference and cookbook.
SPARQL UPDATE requires the server's parsing pipeline. It works automatically when:
- A local server is running (the CLI auto-routes through it by default)
- Using
--remoteto target a remote server
For direct local mode (--direct), use JSON-LD format instead.
# Update Alice's age: find old value, delete it, insert new one
fluree update '{
"@context": {"ex": "http://example.org/"},
"where": [{"@id": "ex:alice", "ex:age": "?oldAge"}],
"delete": [{"@id": "ex:alice", "ex:age": "?oldAge"}],
"insert": [{"@id": "ex:alice", "ex:age": 31}]
}'# Remove all email addresses for alice
fluree update '{
"@context": {"ex": "http://example.org/"},
"where": [{"@id": "ex:alice", "ex:email": "?email"}],
"delete": [{"@id": "ex:alice", "ex:email": "?email"}]
}'# Set all "pending" users to "active"
fluree update '{
"@context": {"ex": "http://example.org/"},
"where": [{"@id": "?person", "ex:status": "pending"}],
"delete": [{"@id": "?person", "ex:status": "pending"}],
"insert": [{"@id": "?person", "ex:status": "active"}]
}'fluree update -f update.json
fluree update -f update.json -m "Updated user statuses"# Requires a running server (fluree server start)
fluree update -e 'PREFIX ex: <http://example.org/>
DELETE { ex:alice ex:age ?oldAge }
INSERT { ex:alice ex:age 31 }
WHERE { ex:alice ex:age ?oldAge }'cat update.json | fluree updatefluree update production -f migration.jsonCommitted t=3, 4 flakes
With remote mode, the full server response is printed as JSON.
The format is auto-detected using this priority:
- Explicit flag (
--format) — always wins - File extension (when using
-for a positional file path):.json,.jsonld→ JSON-LD.rq,.ru,.sparql→ SPARQL UPDATE.cypher,.cyp,.cql→ Cypher
- Content sniffing:
- A
{"cypher": "...", "params": {...}}envelope → Cypher - Valid JSON (full parse, not just first character) → JSON-LD
- Starts with
MATCH,MERGE,DETACH, orCREATE (→ Cypher - Starts with
INSERT,DELETE,PREFIX, orBASE→ SPARQL UPDATE
- A
Override with --format jsonld, --format sparql, or --format cypher.
| Operation | WHERE clause | DELETE | Conditional | Use case |
|---|---|---|---|---|
insert |
No | No | No | Add new data |
upsert |
No | Auto (per subject+predicate) | No | Replace values for known entities |
update |
Yes | Explicit | Yes | Targeted updates, deletes, complex transformations |
- insert - Insert new data
- upsert - Insert or replace existing data
- Update (WHERE/DELETE/INSERT) - Full transaction syntax guide
- query - Query data