<docbook><section><title>VirtTipsAndTricksDeleteTriplesPatternsNotScopedNamedGraph</title><para> </para>
<title> How can I Delete Triple Patterns that are Not Scoped to a Named Graph?</title> How can I Delete Triple Patterns that are Not Scoped to a Named Graph?
<para>Presuming this triple exists in one or more graphs in the store: </para>
<programlisting>{ &lt;http://kingsley.idehen.net/dataspace/person/kidehen#this&gt; 
    &lt;http://xmlns.com/foaf/0.1/knows&gt; 
      &lt;http://id.myopenlink.net/dataspace/person/KingsleyUyiIdehen#this&gt; 
}
</programlisting><para> The SQL query below will delete that triple from all graphs in the store:</para>
<programlisting>DELETE 
  FROM DB.DBA.RDF_QUAD 
 WHERE p = iri_to_id
             (&#39;http://xmlns.com/foaf/0.1/knows&#39;) 
   AND s = iri_to_id 
             (&#39;http://kingsley.idehen.net/dataspace/person/kidehen#this&#39;) 
   AND o = iri_to_id 
             (&#39;http://id.myopenlink.net/dataspace/person/KingsleyUyiIdehen#this&#39;)
;
</programlisting><para> According to <ulink url="http://www.w3.org/TR/2010/WD-sparql11-update-20100126/#t414">SPARQL 1.1 Update</ulink>, the FROM clause which scopes the query to a single graph is optional.
 Thus, the SQL query above can be rewritten to the SPARQL query below, again deleting the matching triple from all graphs in the store:</para>
<para> </para>
<programlisting>DELETE 
  { 
    GRAPH ?g 
      { 
        &lt;http://kingsley.idehen.net/dataspace/person/kidehen#this&gt; 
          &lt;http://xmlns.com/foaf/0.1/knows&gt; 
            &lt;http://id.myopenlink.net/dataspace/person/KingsleyUyiIdehen#this&gt; 
      } 
  }
WHERE 
  { 
    GRAPH ?g 
      { 
        &lt;http://kingsley.idehen.net/dataspace/person/kidehen#this&gt; 
          &lt;http://xmlns.com/foaf/0.1/knows&gt; 
            &lt;http://id.myopenlink.net/dataspace/person/KingsleyUyiIdehen#this&gt; 
      } 
  }
</programlisting><bridgehead class="http://www.w3.org/1999/xhtml:h2"> Related</bridgehead>
<itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="VirtTipsAndTricksGuide">Virtuoso Tips and Tricks Collection</ulink> </listitem>
<listitem><ulink url="http://docs.openlinksw.com/virtuoso/sparqlextensions.html#rdfsparulexamples14">How can I delete triples from a graph?</ulink> </listitem>
<listitem><ulink url="VirtTipsAndTricksGuideDeleteLargeGraphs">How can I delete triples from a &quot;Large&quot; graph?</ulink> </listitem>
<listitem><ulink url="http://docs.openlinksw.com/virtuoso/sparqlextensions.html#rdfsparulexamples15">How can I copy triples from one graph to another?</ulink> </listitem>
<listitem><ulink url="http://docs.openlinksw.com/virtuoso/sparqlextensions.html#rdfsparulexamples16">How can I move triples from one graph to another?</ulink> </listitem>
<listitem><ulink url="http://docs.openlinksw.com/virtuoso/sparqlextensions.html#rdfsparulexamples10">How can I drop a graph?</ulink> </listitem>
<listitem><ulink url="VirtTipsAndTricksDeleteGraphProc">How can I delete graphs using stored procedure?</ulink> </listitem>
</itemizedlist></section></docbook>