CREATE GRAPH
, DROP GRAPH
, CLEAR GRAPH
, and DELETE FROM <graphname>
work in Virtuoso?Here are some details about the CREATE GRAPH
, DROP GRAPH
, CLEAR GRAPH
, and DELETE FROM <graphname>
commands.
Clarifying implications of the various commands in Virtuoso.
In Virtuoso, it does not matter whether CREATE GRAPH
and DROP GRAPH
(or its synonym, CLEAR GRAPH
) are called or not.
Their purpose is to provide compatibility with the original SPARUL that was designed for Jena.
Some Jena triple stores require explicit creation of each graph (like CREATE TABLE
in SQL), report errors if one tries to create a graph twice, and so on.
For Virtuoso, a new graph is not an important system event, because Virtuoso has a single quad-store shared by all graphs.
When a graph is made by CREATE GRAPH
, its name is placed in an auxiliary table that is used solely to signal appropriate errors when a user tries to CREATE
a graph that has already been CREATEd
, or to DROP
a graph which has not been CREATEd
; this table is not used in any way by SPARQL or other subsystems.
In a perfect world, smart development tools will query that table to give hints to a programmer regarding available graphs, but the reality is not so perfect.
There is an important difference between DELETE FROM <graphname> WHERE { ?s ?p ?o }
and CLEAR GRAPH <graphname>
.
Both will delete all triples from the specified graph <graphname>
with equal speed, but CLEAR GRAPH
will also delete free-text index data about occurrences of literals in this specific graph.
CLEAR GRAPH
will therefor make the database slightly more compact and the text search slightly faster.
(Naturally, DROP GRAPH makes CLEAR GRAPH inside, not just DELETE FROM...)
DROP GRAPH
is equivalent of CLEAR GRAPH
.
Both require that the graph has been explicitly CREATEd
. Note: All SPARUL a/k/a SPARQL-Update commands require that the user (i.e., the SPARQL
user for the default /sparql
endpoint) be granted SPARQL_UPDATE"
privilege.
Assume the following sequence of commands to be executed from the /sparql
endpoint:
CREATE GRAPH <qq> callret-0 Create graph <qq> -- done
DROP GRAPH
:
DROP GRAPH <qq> callret-0 Drop graph <qq> -- done
SILENT
option:
DROP SILENT GRAPH <qq> callret-0 Drop silent graph <qq> -- done