Virtuoso Open-Source Wiki
Virtuoso Open-Source, OpenLink Data Spaces, and OpenLink Ajax Toolkit
Advanced Search
Help?
Location: / Dashboard / Main / VirtRemoveTriples

Removing all triples from a Virtuoso Server instance

There are times it can be useful to remove all triples from Virtuoso Server. There are a few ways to accomplish this.

Remove all triples including those in the the system graphs

Use iSQL, either on the command-line or through the Virtuoso Conductor -> Database -> Interactive SQL, to execute this SQL query --

SQL> DELETE FROM DB.DBA.RDF_QUAD ;

Remove all triples except those in the system graphs

Use the built-in RDF_GLOBAL_RESET procedure

  1. When removing large graphs or numbers of triples it is advised/required to change the transaction log mode to autocommit with no transaction logging on each operation, deleting the graph(s) or triples, and then setting the log mode back to its original setting. This is easily done using the Virtuoso log_enable function, with the settings log_enable(3,1).
  2. Use iSQL, either on the command-line or through the Virtuoso Conductor -> Database -> Interactive SQL, to execute this SQL query --

    SQL> RDF_GLOBAL_RESET ();

  3. Now selecting all graphs from your db should return only the system graphs, like so --

    SQL> SPARQL SELECT DISTINCT ?g FROM <http://localhost:8894/> { GRAPH ?g { ?s a ?t } } ; g ANY http://www.openlinksw.com/schemas/virtrdf# No. of rows in result: 1

Write your own procedure

Take all non-system graphs, and for each of them execute:

SPARQL CLEAR GRAPH <The Graph URI here> ;
Powered By Virtuoso