Here are some examples showcasing Virtuoso's support for this functionality:
This example request describes 2 triples to be removed from the named graph identified by the IRI <urn:sparql:tests:delete:data>
<#book2> <http://example.org/ns#price> 42 . <#book2> <http://purl.org/dc/elements/1.1/title> "David Copperfield" . <#book2> <http://purl.org/dc/elements/1.1/creator> "Edmund Wells" .
INSERT DATA { GRAPH <urn:sparql:tests:delete:data> { <#book2> <http://example.org/ns#price> 42 . <#book2> <http://purl.org/dc/elements/1.1/title> "David Copperfield" . <#book2> <http://purl.org/dc/elements/1.1/creator> "Edmund Wells" . } }
DELETE DATA FROM <urn:sparql:tests:delete:data> { <#book2> <http://purl.org/dc/elements/1.1/title> "David Copperfield" ; <http://purl.org/dc/elements/1.1/creator> "Edmund Wells" . }
SELECT * FROM <urn:sparql:tests:delete:data> WHERE { ?s ?p ?o }
This example request removes all statements about anything with a given name of "Fred" from the named graph identified by the IRI <urn:sparql:tests:delete:where> :
<#william> a <http://xmlns.com/foaf/0.1/Person> . <#william> <http://xmlns.com/foaf/0.1/givenName> "William" . <#william> <http://xmlns.com/foaf/0.1/foaf/mbox> <mailto:bill@example> . <#fred> a <http://xmlns.com/foaf/0.1/Person> . <#fred> <http://xmlns.com/foaf/0.1/givenName> "Fred" . <#fred> <http://xmlns.com/foaf/0.1/mbox> <mailto:fred@example> .
INSERT DATA { GRAPH <urn:sparql:tests:delete:where> { <#william> a <http://xmlns.com/foaf/0.1/Person> . <#william> <http://xmlns.com/foaf/0.1/givenName> "William" . <#william> <http://xmlns.com/foaf/0.1/foaf/mbox> <mailto:bill@example> . <#fred> a <http://xmlns.com/foaf/0.1/Person> . <#fred> <http://xmlns.com/foaf/0.1/givenName> "Fred" . <#fred> <http://xmlns.com/foaf/0.1/mbox> <mailto:fred@example> . } }
WITH <urn:sparql:tests:delete:where> DELETE { ?person ?property ?value } WHERE { ?person ?property ?value ; <http://xmlns.com/foaf/0.1/givenName> "Fred" }
SELECT * FROM <urn:sparql:tests:delete:where> WHERE { ?s ?p ?o }
This example request removes both statements naming some resource "Fred" in the graph <urn:sparql:tests:delete:where1> , and also statements about that resource from the graph <urn:sparql:tests:delete:where2> (assuming that some of the resources in the graph <urn:sparql:tests:delete:where1> have corresponding triples in the graph <urn:sparql:tests:delete:where2>).
<#william> a <http://xmlns.com/foaf/0.1/Person> . <#william> <http://xmlns.com/foaf/0.1/givenName> "William" . <#fred> a <http://xmlns.com/foaf/0.1/Person> . <#fred> <http://xmlns.com/foaf/0.1/givenName> "Fred" .
INSERT DATA { GRAPH <urn:sparql:tests:delete:where1> { <#william> a <http://xmlns.com/foaf/0.1/Person> . <#william> <http://xmlns.com/foaf/0.1/givenName> "William" . <#fred> a <http://xmlns.com/foaf/0.1/Person> . <#fred> <http://xmlns.com/foaf/0.1/givenName> "Fred" . } }
<#william> <http://xmlns.com/foaf/0.1/mbox> <mailto:bill@example> . <#fred> <http://xmlns.com/foaf/0.1/mbox> <mailto:fred@example> .
INSERT DATA { GRAPH <urn:sparql:tests:delete:where2> { <#william> <http://xmlns.com/foaf/0.1/mbox> <mailto:bill@example> . <#fred> <http://xmlns.com/foaf/0.1/mbox> <mailto:fred@example> . } }
DELETE WHERE { GRAPH <urn:sparql:tests:delete:where1> { ?person <http://xmlns.com/foaf/0.1/givenName> 'Fred' ; ?property1 ?value1 . } GRAPH <urn:sparql:tests:delete:where2> { ?person ?property2 ?value2 . } }
SELECT * FROM <urn:sparql:tests:delete:where1> WHERE { ?s ?p ?o }
SELECT * FROM <urn:sparql:tests:delete:where2> WHERE { ?s ?p ?o }
This example request removes all statements about anything with a given name of "Fred" from the graph <urn:sparql:tests:delete:informative> . A WITH clause is present, meaning that graph <urn:sparql:tests:delete:informative> is both the one from which triples are being removed and the one which the WHERE clause is matched against:
<#william> a <http://xmlns.com/foaf/0.1/Person> . <#william> <http://xmlns.com/foaf/0.1/givenName> "William" . <#william> <http://xmlns.com/foaf/0.1/mbox> <mailto:bill@example> . <#fred> a <http://xmlns.com/foaf/0.1/Person> . <#fred> <http://xmlns.com/foaf/0.1/givenName> "Fred" . <#fred> <http://xmlns.com/foaf/0.1/mbox> <mailto:fred@example> .
INSERT DATA { GRAPH <urn:sparql:tests:delete:informative> { <#william> a <http://xmlns.com/foaf/0.1/Person> . <#william> <http://xmlns.com/foaf/0.1/givenName> "William" . <#william> <http://xmlns.com/foaf/0.1/mbox> <mailto:bill@example> . <#fred> a <http://xmlns.com/foaf/0.1/Person> . <#fred> <http://xmlns.com/foaf/0.1/givenName> "Fred" . <#fred> <http://xmlns.com/foaf/0.1/mbox> <mailto:fred@example> . } }
WITH <urn:sparql:tests:delete:informative> DELETE { ?person ?property ?value } WHERE { ?person ?property ?value ; <http://xmlns.com/foaf/0.1/givenName> 'Fred' }
SELECT * FROM <urn:sparql:tests:delete:informative> WHERE { ?s ?p ?o }