How to delete the specified triples on the isql command line of virtuoso?

There are no SPARQL specifications/methods for deleting triples based on the content of a RDF dataset file.

In Virtuoso this could possibly be achieved using isql by:

  1. Loading the remove.nt file containing the triples to be removed into a temporary graph in Virtuoso using the RDF Bulk Loader

  2. Set log_enable(3,1); as recommended when deleting large number of triples in Virtuoso.

  3. Run the following SQL query to delete the triples directly from the RDF_QUAD table:

delete from rdf_quad a where exists (select 1 from rdf_quad b where a.s = b.s and a.p = b.p and a.o = b.o and b.g = iri_to_id('temp_graph_name') );

where temp_graph_name is the name of the temp graph the remove.nt triples have been loaded into.

Note, as always, before embarking on such an operation, ensure a Full Backup of the Virtuoso database is in place, should you need to revert back to the previous state.