-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSPARQL 1.1 Update.input.html
1673 lines (1597 loc) · 136 KB
/
SPARQL 1.1 Update.input.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!--?xml version="1.0" encoding="UTF-8"?-->
<html lang="EN">
<head>
<meta name="generator" content="HTML Tidy for HTML5 for Linux version 5.6.0">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>SPARQL 1.1 Update</title>
<style type="text/css">
@import url("local.css");
code { font-family: monospace; }
div.constraint,
div.issue,
div.note,
div.notice { margin-left: 2em; }
ol.enumar { list-style-type: decimal; }
ol.enumla { list-style-type: lower-alpha; }
ol.enumlr { list-style-type: lower-roman; }
ol.enumua { list-style-type: upper-alpha; }
ol.enumur { list-style-type: upper-roman; }
div.exampleInner pre { margin-left: 1em;
margin-top: 0em; margin-bottom: 0em}
div.exampleOuter {border: 4px double gray;
margin: 0em; padding: 0em}
div.exampleInner { background-color: #d5dee3;
border-top-width: 4px;
border-top-style: double;
border-top-color: #d3d3d3;
border-bottom-width: 4px;
border-bottom-style: double;
border-bottom-color: #d3d3d3;
padding: 4px; margin: 0em }
div.exampleWrapper { margin: 4px }
div.exampleHeader { font-weight: bold;
margin: 4px}
em.rfc2119 { text-transform: lowercase;
font-variant: small-caps;
font-style: normal; }
</style>
<link rel="stylesheet" type="text/css" href="http://www.w3.org/StyleSheets/TR/W3C-REC.css">
</head>
<body>
<div class="head">
<p><a href="http://www.w3.org/"><img src="SPARQL%201.1%20Update_files/w3c_home.svg" alt="W3C" width="72" height="48"></a></p>
<h1><a name="title" id="title"></a>SPARQL 1.1 Update</h1>
<h2><a name="w3c-doctype" id="w3c-doctype"></a>W3C Recommendation 21 March 2013</h2>
<dl>
<dt>This version:</dt>
<dd><a href="http://www.w3.org/TR/2013/REC-sparql11-update-20130321/">http://www.w3.org/TR/2013/REC-sparql11-update-20130321/</a></dd>
<dt>Latest version:</dt>
<dd><a href="http://www.w3.org/TR/sparql11-update/">http://www.w3.org/TR/sparql11-update/</a></dd>
<dt>Previous version:</dt>
<dd><a href="http://www.w3.org/TR/2012/PR-sparql11-update-20121108/">http://www.w3.org/TR/2012/PR-sparql11-update-20121108/</a></dd>
<dt>Editors:</dt>
<dd>Paula Gearon <a href="mailto:[email protected]"><[email protected]></a></dd>
<dd>Alexandre Passant, DERI Galway at the National University of Ireland, Galway, Ireland <a href="mailto:[email protected]"><[email protected]></a></dd>
<dd>Axel Polleres, Siemens AG <a href="mailto:[email protected]"><[email protected]></a></dd>
</dl>
<p>Please refer to the <a href="http://www.w3.org/2013/sparql-errata#sparql11-update"><strong>errata</strong></a> for this document, which may include some normative corrections.</p>
<p>See also <a href="http://www.w3.org/2003/03/Translations/byTechnology?technology=sparql11-update"><strong>translations</strong></a>.</p>
<p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 2013 <a href="http://www.w3.org/"><acronym title=
"World Wide Web Consortium">W3C</acronym></a><sup>®</sup> (<a href="http://www.csail.mit.edu/"><acronym title="Massachusetts Institute of Technology">MIT</acronym></a>, <a href=
"http://www.ercim.eu/"><acronym title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>, <a href="http://www.keio.ac.jp/">Keio</a>, <a href=
"http://ev.buaa.edu.cn/">Beihang</a>), All Rights Reserved. W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href=
"http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.</p>
</div>
<hr>
<div>
<h2><a name="abstract" id="abstract"></a>Abstract</h2>
<p>This document describes SPARQL 1.1 Update, an update language for RDF graphs. It uses a syntax derived from the SPARQL Query Language for RDF. Update operations are performed on a collection
of graphs in a Graph Store. Operations are provided to update, create, and remove RDF graphs in a Graph Store.</p>
</div>
<div>
<h2><a name="status" id="status"></a>Status of this Document</h2>
<h4 id="may-be">May Be Superseded</h4>
<p><em>This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision
of this technical report can be found in the <a href="http://www.w3.org/TR/">W3C technical reports index</a> at http://www.w3.org/TR/.</em></p>
<h4 id="related">Set of Documents</h4>
<p>This document is one of eleven SPARQL 1.1 Recommendations produced by the <a href="http://www.w3.org/2001/sw/DataAccess/">SPARQL Working Group</a>:</p>
<ol>
<li><a href="http://www.w3.org/TR/2013/REC-sparql11-overview-20130321">SPARQL 1.1 Overview</a></li>
<li><a href="http://www.w3.org/TR/2013/REC-sparql11-query-20130321">SPARQL 1.1 Query Language</a></li>
<li><a href="http://www.w3.org/TR/2013/REC-sparql11-update-20130321">SPARQL 1.1 Update</a> (this document)</li>
<li><a href="http://www.w3.org/TR/2013/REC-sparql11-service-description-20130321">SPARQL1.1 Service Description</a></li>
<li><a href="http://www.w3.org/TR/2013/REC-sparql11-federated-query-20130321">SPARQL 1.1 Federated Query</a></li>
<li><a href="http://www.w3.org/TR/2013/REC-sparql11-results-json-20130321">SPARQL 1.1 Query Results JSON Format</a></li>
<li><a href="http://www.w3.org/TR/2013/REC-sparql11-results-csv-tsv-20130321">SPARQL 1.1 Query Results CSV and TSV Formats</a></li>
<li><a href="http://www.w3.org/TR/2013/REC-rdf-sparql-XMLres-20130321">SPARQL Query Results XML Format (Second Edition)</a></li>
<li><a href="http://www.w3.org/TR/2013/REC-sparql11-entailment-20130321">SPARQL 1.1 Entailment Regimes</a></li>
<li><a href="http://www.w3.org/TR/2013/REC-sparql11-protocol-20130321">SPARQL 1.1 Protocol</a></li>
<li><a href="http://www.w3.org/TR/2013/REC-sparql11-http-rdf-update-20130321">SPARQL 1.1 Graph Store HTTP Protocol</a></li>
</ol>
<h4 class="no-toc no-num" id="status-changes">No Substantive Changes</h4>
<p>There have been no substantive changes to this document since the <a href="http://www.w3.org/TR/2012/PR-sparql11-update-20121108/">previous version</a>. Minor editorial changes, if any, are
detailed in the <a href="#changes-since-pr">change log</a> and visible in the <a href="https://www.w3.org/TR/sparql11-update/diff">color-coded diff</a>.</p>
<h4 class="no-toc no-num" id="please">Please Send Comments</h4>
<p>Please send any comments to <a class="mailto" href="mailto:[email protected]">[email protected]</a> (<a class="http" href=
"http://lists.w3.org/Archives/Public/public-rdf-dawg-comments/">public archive</a>). Although work on this document by the <a href="http://www.w3.org/2009/sparql/">SPARQL Working Group</a> is
complete, comments may be addressed in the <a href="http://www.w3.org/2013/sparql-errata">errata</a> or in future revisions. Open discussion is welcome at <a class="mailto" href=
"mailto:[email protected]">[email protected]</a> (<a class="http" href="http://lists.w3.org/Archives/Public/public-sparql-dev/">public archive</a>).</p>
<h4 class="no-toc no-num" id="endorsement">Endorsed By W3C</h4>
<p><em>This document has been reviewed by W3C Members, by software developers, and by other W3C groups and interested parties, and is endorsed by the Director as a W3C Recommendation. It is a
stable document and may be used as reference material or cited from another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its
widespread deployment. This enhances the functionality and interoperability of the Web.</em></p>
<h4 id="patents">Patents</h4>
<p><em>This document was produced by a group operating under the <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 W3C Patent Policy</a>. W3C maintains a <a href=
"http://www.w3.org/2004/01/pp-impl/35463/status" rel="disclosure">public list of any patent disclosures</a> made in connection with the deliverables of the group; that page also includes
instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains <a href=
"http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a> must disclose the information in accordance with <a href=
"http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section 6 of the W3C Patent Policy</a>.</em></p>
</div>
<div class="toc">
<h2><a name="contents" id="contents"></a>Table of Contents</h2>
<p class="toc">1 <a href="#sec-intro">Introduction</a><br>
1.1 <a href="#documentConventions">Document Conventions</a><br>
1.1.1 <a href="#languageForm">Language Form</a><br>
1.1.2 <a href="#terminology">Terminology</a><br>
2 <a href="#graphStore">The Graph Store</a><br>
2.1 <a href="#graphStoreQueryServices">Graph Store and SPARQL Query Services</a><br>
2.2 <a href="#updateServices">SPARQL 1.1 Update Services</a><br>
2.3 <a href="#entailmentConsistency">Entailment and Consistency</a><br>
3 <a href="#updateLanguage">SPARQL 1.1 Update Language</a><br>
3.1 <a href="#graphUpdate">Graph Update</a><br>
3.1.1 <a href="#insertData">INSERT DATA</a><br>
3.1.2 <a href="#deleteData">DELETE DATA</a><br>
3.1.3 <a href="#deleteInsert">DELETE/INSERT</a><br>
3.1.3.1 <a href="#delete">DELETE (Informative)</a><br>
3.1.3.2 <a href="#insert">INSERT (Informative)</a><br>
3.1.3.3 <a href="#deleteWhere">DELETE WHERE</a><br>
3.1.4 <a href="#load">LOAD</a><br>
3.1.5 <a href="#clear">CLEAR</a><br>
3.2 <a href="#graphManagement">Graph Management</a><br>
3.2.1 <a href="#create">CREATE</a><br>
3.2.2 <a href="#drop">DROP</a><br>
3.2.3 <a href="#copy">COPY</a><br>
3.2.4 <a href="#move">MOVE</a><br>
3.2.5 <a href="#add">ADD</a><br>
4 <a href="#formalModel">SPARQL Update Formal Model</a><br>
4.1 <a href="#formalModelGeneral">General Definitions</a><br>
4.1.1 <a href="#def_graphstore">Graph Store</a><br>
4.1.2 <a href="#def_updateoperation">Abstract Update Operation</a><br>
4.2 <a href="#formalModelAuxiliary">Auxiliary Definitions</a><br>
4.2.1 <a href="#def_datasetUnion">Dataset-UNION</a><br>
4.2.2 <a href="#def_datasetDiff">Dataset-DIFF</a><br>
4.2.3 <a href="#def_datasetQuadPattern">Dataset( QuadPattern, μ, DS, GS )</a><br>
4.2.4 <a href="#def_datasetPattern">Dataset( QuadPattern, P, DS, GS )</a><br>
4.3 <a href="#formalModelGraphUpdate">Graph Update Operations</a><br>
4.3.1 <a href="#def_insertdataoperation">Insert Data Operation</a><br>
4.3.2 <a href="#def_deletedataoperation">Delete Data Operation</a><br>
4.3.3 <a href="#def_deleteinsertoperation">Delete Insert Operation</a><br>
4.3.4 <a href="#def_loadoperation">Load Operation</a><br>
4.3.5 <a href="#def_clearOperation">Clear Operation</a><br>
4.4 <a href="#formalModelGraphMgt">Graph Management Operations</a><br>
4.4.1 <a href="#def_createOperation">Create Operation</a><br>
4.4.2 <a href="#def_dropOperation">Drop Operation</a><br>
4.5 <a href="#mappingRequestsToOperations">Mapping Update Requests to the Formal Model</a><br>
5 <a href="#conformance">Conformance</a><br></p>
<h3><a name="appendices" id="appendices"></a>Appendices</h3>
<p class="toc">A <a href="#security">Security Considerations (Informative)</a><br>
B <a href="#mediaType">Internet Media Type, File Extension and Macintosh File Type</a><br>
C <a href="#grammar">SPARQL 1.1 Update Grammar</a><br>
D <a href="#sec-bibliography">References</a><br>
D.1 <a href="#sec-existing-stds">Normative References</a><br>
D.2 <a href="#null">Other References</a><br></p>
</div>
<hr>
<div class="body">
<div class="div1">
<h2><a name="sec-intro" id="sec-intro"></a>1 Introduction</h2>
<p>SPARQL 1.1 Update is intended to be a standard language for specifying and executing updates to RDF graphs in a Graph Store.</p>
<p>SPARQL 1.1 Update provides the following facilities:</p>
<ul>
<li>Insert triples into an RDF graph in the Graph Store.</li>
<li>Delete triples from an RDF graph in the Graph Store.</li>
<li>Load an RDF graph into the Graph Store.</li>
<li>Clear an RDF graph in the Graph Store.</li>
<li>Create a new RDF graph in a Graph Store.</li>
<li>Drop an RDF graph from a Graph Store.</li>
<li>Copy, move, or add the content of one RDF graph in the Graph Store to another.</li>
<li>Perform a group of update operations as a single action.</li>
</ul>
<p>This document is particularly related to the following other specification documents:</p>
<ul>
<li><a href="http://www.w3.org/TR/sparql11-query/">SPARQL 1.1 Query Language</a></li>
<li><a href="http://www.w3.org/TR/sparql11-http-rdf-update/">SPARQL 1.1 Graph Store HTTP Protocol</a></li>
<li><a href="http://www.w3.org/TR/sparql11-protocol/">SPARQL 1.1 Protocol for RDF</a></li>
</ul>
<p>SPARQL 1.1 Update is a companion language and envisaged to be used in conjunction with the <em>SPARQL 1.1 Query language</em>. The present document refers to the grammar and several
definitions from the <em>SPARQL 1.1 Query language</em> specification.</p>
<p>The <em>SPARQL 1.1 Graph Store HTTP Protocol</em> specification employs the HTTP protocol to perform update operations using standard HTTP methods, such as PUT and DELETE. While providing a
simple and well known API, it is necessarily restricted in its operations due to the limited set of methods in the HTTP protocol. In contrast, SPARQL 1.1 Update permits multiple modifications
in a single operation, and can use complex SPARQL queries for constructing data to be inserted, or choosing data to be deleted. Also, the use of an update language facilitates operations over
proprietary APIs and connections that may not involve HTTP.</p>
<p>The <em>SPARQL 1.1 Protocol for RDF</em> specification describes a means of conveying SPARQL 1.1 Query and SPARQL 1.1 Update operations from clients to a <a href=
"http://www.w3.org/TR/sparql11-protocol/#intro">SPARQL query processing service</a>, and for returning appropriate results. Together with the SPARQL 1.1 Query and SPARQL 1.1 Update (this
document) specifications, these form an alternative to the <em>SPARQL 1.1 Graph Store HTTP Protocol</em> with comprehensive, though more complex functionality.</p>
<div class="div2">
<h3><a name="documentConventions" id="documentConventions"></a>1.1 Document Conventions</h3>
<div class="div3">
<h4><a name="languageForm" id="languageForm"></a>1.1.1 Language Form</h4>
<p>The operations in this document contain language forms describing their use. These are meant as illustrative forms of the formal grammar described in the <a href=
"http://www.w3.org/TR/sparql11-query/#sparqlGrammar">SPARQL 1.1 Query</a> document. Any discrepancies between the language forms in this document and the grammar in SPARQL 1.1 Query will
defer to the formal grammar in SPARQL 1.1 Query.</p>
<p>Language forms are shown informally in this document as for instance:</p>
<pre class="defn">( <strong>WITH</strong> <em><a href="http://www.w3.org/TR/sparql11-query/#rIRIREF">IRIref</a></em> )?
( ( <em><a href="http://www.w3.org/TR/sparql11-query/#rDeleteClause">DeleteClause</a> <a href="http://www.w3.org/TR/sparql11-query/#rInsertClause">InsertClause</a></em>? ) | <em><a href=
"http://www.w3.org/TR/sparql11-query/#rInsertClause">InsertClause</a></em> )
( <strong>USING</strong> ( <strong>NAMED</strong> )? <em><a href="http://www.w3.org/TR/sparql11-query/#rIRIREF">IRIref</a></em> )*
<strong>WHERE</strong> <code><em><a href="http://www.w3.org/TR/sparql11-query/#rGroupGraphPattern">GroupGraphPattern</a></em></code></pre>
<p>Unlike other forms of EBNF where square brackets denote optionality, here <code><strong>[]</strong></code> is used for blank nodes, as in SPARQL Query. <code>|</code> is used to denote
alternatives, <code>()</code> is used for grouping terms, <code>?</code> indicates 0 or 1 occurrence of a term, <code>*</code> indicates 0 or more occurrences, and <code>+</code> indicates
1 or more occurrences.</p>
<p><code><strong>BOLD</strong></code> indicates language keywords. <code><em>Italics</em></code> indicate syntactic items defined in the <a href=
"http://www.w3.org/TR/sparql11-query/#sparqlGrammar">SPARQL 1.1 Query Grammar</a>, where we occasionally refer to productions by links. Unitalicized text indicates a local term that will
have a more complex (and exact) definition in the formal grammar.</p>
<p>Example update requests are shown as follows:</p>
<pre class="query">PREFIX dc: <http://purl.org/dc/elements/1.1/>
INSERT { <http://example/egbook> dc:title "This is an example title" } WHERE {}</pre>
<div class="note">
<p class="prefix"><strong>Note:</strong></p><code>PREFIX</code> definitions and the <a href="http://www.w3.org/TR/sparql11-query/#QSynIRI">syntax for IRIs</a> in update requests in
general follow the same conventions as in the <a href="http://www.w3.org/TR/sparql11-query/">SPARQL1.1 Query Language</a>.
</div>
<p>Data is shown in Turtle syntax as follows:</p>
<pre class="data">@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix : <http://example.org/books/> .
:book0 dc:title "SPARQL Tutorial" .</pre>
</div>
<div class="div3">
<h4><a name="terminology" id="terminology"></a>1.1.2 Terminology</h4>
<p>When this document uses the words <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>, <em class="rfc2119" title="Keyword in RFC 2119 context">MUST NOT</em>, <em class=
"rfc2119" title="Keyword in RFC 2119 context">SHOULD</em>, <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD NOT</em>, <em class="rfc2119" title=
"Keyword in RFC 2119 context">MAY</em> and <strong>recommended</strong>, and the words appear as emphasized text, they must be interpreted as described in <a href=
"http://www.faqs.org/rfcs/rfc2119.html">RFC 2119</a> [RFC2119].</p>
<p>The following terms are also in use throughout this document:</p>
<ul>
<li><a name="operation" id="operation">Operation</a> - An action to be performed that results in the modification of data in a <a href="#graphStore">Graph Store</a> expressible as a
single command, e.g. <a href="#insertData">INSERT</a> or <a href="#deleteData">DELETE</a>.</li>
<li><a name="request" id="request">Request</a> - A sequence of zero or more operations that is sent to a Graph Store. When using the <a href=
"http://www.w3.org/TR/sparql11-protocol/">SPARQL 1.1 Protocol for RDF</a> a request will be one HTTP POST.</li>
</ul>
<p>The following terms are also used in this document as defined in the SPARQL 1.1 Query Language:</p>
<ul>
<li><code><em><a href="http://www.w3.org/TR/sparql11-query/#rQuadPattern">QuadPattern</a></em></code> - A syntactic construct that refers to a set of triple patterns, similar to
<code><em><a href="http://www.w3.org/TR/sparql11-query/#rConstructTriples">ConstructTriples</a></em></code>, but potentially involving the <code>GRAPH</code> keyword to indicate that a
set of triples is to be inserted into/deleted from a named graph.</li>
<li><code><em><a href="http://www.w3.org/TR/sparql11-query/#rQuadData">QuadData</a></em></code> - A <code><em><a href=
"http://www.w3.org/TR/sparql11-query/#rQuadPattern">QuadPattern</a></em></code> without variables.</li>
<li><code><em><a href="http://www.w3.org/TR/sparql11-query/#rGroupGraphPattern">GroupGraphPattern</a></em></code> - A syntactic construct for referring to a set of triples, possibly with
complex constraints.</li>
</ul>
</div>
</div>
</div>
<div class="div1">
<h2><a name="graphStore" id="graphStore"></a>2 The Graph Store</h2>
<p>A Graph Store is a mutable container of RDF graphs managed by a single service. Similar to an <a href="http://www.w3.org/TR/sparql11-query/#sparqlDataset">RDF Dataset</a> operated on by the
<a href="http://www.w3.org/TR/sparql11-query/">SPARQL 1.1 Query Language</a>, a Graph Store contains one (unnamed) slot holding a <em>default graph</em> and zero or more named slots holding
<em>named graphs</em>. Operations <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em> specify graphs to be modified, or they <em class="rfc2119" title=
"Keyword in RFC 2119 context">MAY</em> rely on a <em>default graph</em> for that operation. Unless overridden (for instance, by the SPARQL protocol), the unnamed graph for the store will be the
default graph for any operations on that store. Depending on implementation, the unnamed graph <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em> refer to a separate graph, a
graph describing the named graphs, a representation of a union of other graphs, etc.</p>
<p>Unlike an RDF Dataset, named graphs can be added to or deleted from a Graph Store. A Graph Store needs not be authoritative for the graphs it contains. That means a Graph Store can keep
local copies of RDF graphs defined elsewhere on the Web and modify those copies independently of the original graph.</p>
<p>In the simple case where there is one unnamed graph and no named graphs, SPARQL 1.1 Update can be used as a graph update language (as opposed to a Graph Store update language).</p>
<p>The information how a Graph Store is accessed is defined in the protocol and Graph Store protocol specs. A Graph Store is accessible by either an update service (cf. protocol) or via the
Graph Store protocol (cf. Graph Store protocol). In either case the Graph Store is hidden behind the service, making it accessible via the URI of a SPARQL update service or via a URI that
responds to the Graph Store protocol.</p>
<p>A formal definition for Graph Stores and how SPARQL 1.1 Update affects them is described in the <a href="#formalModel">SPARQL 1.1 Update Formal Model section</a>.</p>
<div class="div2">
<h3><a name="graphStoreQueryServices" id="graphStoreQueryServices"></a>2.1 Graph Store and SPARQL Query Services</h3>
<p>A service (often referred to by the informal term <em>SPARQL endpoint</em>) that accepts and processes update requests is referred to as an <em>update service</em>. There is no presumption
that the Graph Store managed by an update service exactly corresponds to any RDF Dataset offered by some query service. A query service <em class="rfc2119" title=
"Keyword in RFC 2119 context">MAY</em> offer an RDF Dataset formed from graphs that are part of an update service's Graph Store. The graphs in the query service's RDF Dataset <em class=
"rfc2119" title="Keyword in RFC 2119 context">MAY</em> be a subset of the graphs in the update service's Graph Store. Furthermore, the query service's RDF Dataset and the update service's
Graph Store <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em> use different names for the same graphs.</p>
</div>
<div class="div2">
<h3><a name="updateServices" id="updateServices"></a>2.2 SPARQL 1.1 Update Services</h3>
<p>SPARQL 1.1 Update requests are sequences of operations.</p>
<p>Each request <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em> be treated atomically by a SPARQL 1.1 Update service. The term 'atomically' means that a single request
will result in either no effect or a complete effect, regardless of the number of operations that may be present in the request. Any resulting concurrency issues will be a matter for each
implementation to consider according to its own architecture. In particular, using the <a href="http://www.w3.org/TR/sparql11-federated-query/#service">SERVICE</a> keyword in the WHERE clause
of operations in an Update request will usually result in a loss of atomicity.</p>
<p>In the case of two different update services, whose respective Graph Stores contain graphs with the same names, there is no presumption that the updates done through one service will be
propagated to the other, as the stores are independent entities. The behaviour of these services with respect to each other (such as automatic synchronization after updates) is implementation
dependent.</p>
</div>
<div class="div2">
<h3><a name="entailmentConsistency" id="entailmentConsistency"></a>2.3 Entailment and Consistency</h3>
<p>If the store is capable of calculating entailed answers, see <a href="http://www.w3.org/TR/sparql11-entailment/">SPARQL 1.1 Entailment Regimes</a>, then it is possible for update
operations to interact with entailed data. In particular, a <code>DELETE</code> operation may attempt to remove entailed statements without actual effects.</p>
<p>After an update request is completed, a store that performs consistency checking with respect to a particular entailment regime on its graphs <em class="rfc2119" title=
"Keyword in RFC 2119 context">MAY</em> check the new state of the Graph Store for consistency. If inconsistency is detected, such a store <em class="rfc2119" title=
"Keyword in RFC 2119 context">MAY</em> return an error to the request.</p>
<p>Also of note is that some stores may be capable of performing entailments with respect to an ontology capable of higher level processing, such as RDFS or OWL. Updates may interact with
these entailment regimes in these systems.</p>
</div>
</div>
<div class="div1">
<h2><a name="updateLanguage" id="updateLanguage"></a>3 SPARQL 1.1 Update Language</h2>
<p>SPARQL 1.1 Update supports two categories of update operations on a Graph Store:</p>
<ul>
<li>Graph Update - addition and removal of triples from some graphs within the Graph Store.</li>
<li>Graph Management - creating and deletion of graphs within the Graph Store, as well as convenient shortcuts for graph update operations often used during graph management (to add, move,
and copy graphs).</li>
</ul>
<p>A request is a sequence of operations and is terminated by EOF (End of File). Multiple operations are separated by a ';' (semicolon) character. A semicolon after the last operation in a
request is optional. Implementations <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> ensure that the operations of a single request are executed in a fashion that guarantees
the same effects as executing them sequentially in the order they appear in the request.</p>
<p>Operations all result either in <em>success</em> or <em>failure</em>. A <em>failure</em> result <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em> be accompanied by extra
information, indicating that some portion of the operations in the request were successful. This document does not stipulate the exact form of the result, as that will be dependent on the
interface being used, for instance the <a href="http://www.w3.org/TR/sparql11-protocol/">SPARQL 1.1 protocol</a> via HTTP or a programmatic API. If multiple operations are present in a single
request, then a result of <em>failure</em> from any operation <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> abort the sequence of operations, causing the subsequent
operations to be ignored.</p>
<p>The formal semantics of the following operations is defined in <a href="#formalModel">Section 4</a> of this document.</p>
<div class="div2">
<h3><a name="graphUpdate" id="graphUpdate"></a>3.1 Graph Update</h3>
<p>Graph update operations change existing graphs in the Graph Store but do not explicitly delete nor create them. Non-empty inserts into non-existing graphs will, however,
<em>implicitly</em> create those graphs, i.e., an implementation fulfilling an update request <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em> silently an automatically
create graphs that do not exist before triples are inserted into them, and <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> return with failure if it fails to do so for any
reason. (For example, the implementation may have insufficient resources, or an implementation may only provide an update service over a fixed set of graphs and the implicitly created graph
is not within this fixed set). An implementation <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em> remove graphs that are left empty after triples are removed from them.</p>
<p>If a graph is created implicitly by an update operation, then the behavior of the Graph Store <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be functionally equivalent
to its behavior if the graph had been created explicitly by a CREATE operation.</p>
<p>SPARQL 1.1 Update provides these graph update operations:</p>
<ul>
<li>The <code><a href="#insertData">INSERT DATA</a></code> operation adds some triples, given inline in the request, into a graph. This <em class="rfc2119" title=
"Keyword in RFC 2119 context">SHOULD</em> create the destination graph if it does not exist. If the graph does not exist and it can not be created for any reason, then a failure <em class=
"rfc2119" title="Keyword in RFC 2119 context">MUST</em> be returned.</li>
<li>The <code><a href="#deleteData">DELETE DATA</a></code> operation removes some triples, given inline in the request, if the respective graph contains those.</li>
<li>The fundamental pattern-based actions for graph updates are <code>INSERT</code> and <code>DELETE</code> (which can co-occur in a single <code><a href=
"#deleteInsert">DELETE/INSERT</a></code> operation). These actions consist of groups of triples to be deleted and groups of triples to be added. The specification of the triples is based on
query patterns. The difference between <code>INSERT</code> / <code>DELETE</code> and <code>INSERT DATA</code> / <code>DELETE DATA</code> is that <code>INSERT DATA</code> and <code>DELETE
DATA</code> do not substitute bindings into a template from a pattern. The <code>DATA</code> forms require concrete data (triple templates containing variables within <code>DELETE
DATA</code> and <code>INSERT DATA</code> operations are disallowed and blank nodes are disallowed within <code>DELETE DATA</code>, see Notes 8+9 in the <a href=
"http://www.w3.org/TR/sparql11-query/#sparqlGrammar">grammar</a>). Having specific operations for concrete data means that a request can be streamed so that large, pure-data updates
can be done.</li>
<li>The <code><a href="#load">LOAD</a></code> operation reads the contents of a document representing a graph into a graph in the Graph Store.</li>
<li>The <code><a href="#clear">CLEAR</a></code> operation removes all the triples in (one or more) graphs.</li>
</ul>
<div class="div3">
<h4><a name="insertData" id="insertData"></a>3.1.1 INSERT DATA</h4>
<p>The <code><a href="#insertData">INSERT DATA</a></code> operation adds some triples, given inline in the request, into the Graph Store:</p>
<pre class="defn"><strong>INSERT DATA </strong> <em><code><a href="http://www.w3.org/TR/sparql11-query/#rQuadData">QuadData</a></code></em>
</pre>
<p>where <code><em>QuadData</em></code> are formed by <code><em><a href="http://www.w3.org/TR/sparql11-query/#rTriplesTemplate">TriplesTemplate</a></em></code>s, i.e., sets of triple
patterns, optionally wrapped into a <code>GRAPH</code> block.</p>
<pre class="defn"> <code>( <strong>GRAPH</strong> <em><a href="http://www.w3.org/TR/sparql11-query/#rVarOrIri">VarOrIri</a></em> )? { <em><a href=
"http://www.w3.org/TR/sparql11-query/#rTriplesTemplate">TriplesTemplate</a></em>? }</code>
</pre>
<p>Variables in <code><em>QuadData</em></code>s are disallowed in <code>INSERT DATA</code> requests (see Notes 8 in the <a href=
"http://www.w3.org/TR/sparql11-query/#sparqlGrammar">grammar</a>). That is, the <code>INSERT DATA</code> statement only allows to insert ground triples. Blank nodes in
<code><em>QuadData</em></code>s are assumed to be disjoint from the blank nodes in the Graph Store, i.e., will be inserted with "fresh" blank nodes.</p>
<p>If no graph is described in the <code><em>QuadData</em></code>, then the default graph is presumed. If data is inserted into a graph that does not exist in the Graph Store, it <em class=
"rfc2119" title="Keyword in RFC 2119 context">SHOULD</em> be created (there may be implementations providing an update service over a fixed set of graphs which in such case <em class=
"rfc2119" title="Keyword in RFC 2119 context">MUST</em> return with failure for update requests that insert data into an unallowed graph).</p>
<p>Note that a triple <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em> be considered to be "processed" with no action if that triple already exists in the graph. Further,
note that</p>
<pre class="query">INSERT DATA { GRAPH <g> {} } ...</pre>
<p>does not create <code><g></code>. If a user intends to just create a graph, then the graph management operations (<code>CREATE</code>/<code>LOAD</code>) may be used prior to any
insertion operations.</p>
<p><strong>Example 1: <a name="example_1" id="example_1"></a>Adding some triples to a graph</strong></p>
<p>This snippet describes two RDF triples to be inserted into the default graph of the Graph Store.</p>
<pre class="query">PREFIX dc: <http://purl.org/dc/elements/1.1/>
INSERT DATA
{
<http://example/book1> dc:title "A new book" ;
dc:creator "A.N.Other" .
}</pre>
<p>Data before:</p>
<pre class="data"><strong># Default graph</strong>
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix ns: <http://example.org/ns#> .
<http://example/book1> ns:price 42 .</pre>
<p>Data after:</p>
<pre class="data"><strong># Default graph</strong>
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix ns: <http://example.org/ns#> .
<http://example/book1> ns:price 42 .
<http://example/book1> dc:title "A new book" .
<http://example/book1> dc:creator "A.N.Other" .</pre>
<p><strong>Example 2:</strong></p>
<p><a name="example_2" id="example_2"></a>This SPARQL 1.1 Update request adds a triple to provide the price of a book. As opposed to the previous example, which affected the default graph,
the requested change happens in the named graph identified by the IRI <code>http://example/bookStore</code>.</p>
<pre class="query">PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX ns: <http://example.org/ns#>
INSERT DATA
{ GRAPH <http://example/bookStore> { <http://example/book1> ns:price 42 } }
</pre>
<p>Data before:</p>
<pre class="data"><strong># Graph: http://example/bookStore</strong>
@prefix dc: <http://purl.org/dc/elements/1.1/> .
<http://example/book1> dc:title "Fundamentals of Compiler Design" .
</pre>
<p>Data after:</p>
<pre class="data"><strong># Graph: http://example/bookStore</strong>
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix ns: <http://example.org/ns#> .
<http://example/book1> dc:title "Fundamentals of Compiler Design" .
<http://example/book1> ns:price 42 .
</pre>
</div>
<div class="div3">
<h4><a name="deleteData" id="deleteData"></a>3.1.2 DELETE DATA</h4>
<p>The <code><a href="#deleteData">DELETE DATA</a></code> operation removes some triples, given inline in the request, if the respective graphs in the Graph Store contain those:</p>
<pre class="defn"><strong>DELETE DATA </strong> <em><code><a href="http://www.w3.org/TR/sparql11-query/#rQuadData">QuadData</a></code></em>
</pre>
<p><code><em>QuadData</em></code> denotes triples to be removed and is as described in <code><a href="#insertData">INSERT DATA</a></code>, with the difference that in a <code>DELETE
DATA</code> operation neither variables nor blank nodes are allowed (see Notes 8+9 in the <a href="http://www.w3.org/TR/sparql11-query/#sparqlGrammar">grammar</a>).</p>
<p>As with <code>INSERT DATA</code>, <code>DELETE DATA</code> is meant for deletion of ground triples data which is why <code><em>QuadData</em></code> that contains variables or blank nodes
is disallowed in <code>DELETE DATA</code> operations. The <code><a href="#deleteInsert">DELETE/INSERT</a></code> operation can be used to remove triples containing blank nodes.</p>
<p>Note that the deletion of non-existing triples has no effect, i.e., triples in the <code><em>QuadData</em></code> that did not exist in the Graph Store are ignored. Blank nodes are not
permitted in the <code><em>QuadData</em></code>, as these do not match any existing data.</p>
<p><strong>Example 3: Removing triples from a graph</strong></p>
<p><a name="example_3" id="example_3"></a>This request describes 2 triples to be removed from the default graph of the Graph Store.</p>
<pre class="query">PREFIX dc: <http://purl.org/dc/elements/1.1/>
DELETE DATA
{
<http://example/book2> dc:title "David Copperfield" ;
dc:creator "Edmund Wells" .
}</pre>
<p>Data before:</p>
<pre class="data"><strong># Default graph</strong>
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix ns: <http://example.org/ns#> .
<http://example/book2> ns:price 42 .
<http://example/book2> dc:title "David Copperfield" .
<http://example/book2> dc:creator "Edmund Wells" .</pre>
<p>Data after:</p>
<pre class="data"><strong># Default graph</strong>
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix ns: <http://example.org/ns#> .
<http://example/book2> ns:price 42 .</pre>
<p><strong>Example 4:</strong></p>
<p><a name="example_4" id="example_4"></a>This SPARQL 1.1 Update request consists of two operations, including a triple to be deleted and a triple to be added (used here to correct a book
title). As opposed to the previous example, which affected the default graph, the requested change happens in the named graph identified by the IRI
<code>http://example/bookStore</code>.</p>
<pre class="query">PREFIX dc: <http://purl.org/dc/elements/1.1/>
DELETE DATA
{ GRAPH <http://example/bookStore> { <http://example/book1> dc:title "Fundamentals of Compiler Desing" } } ;
PREFIX dc: <http://purl.org/dc/elements/1.1/>
INSERT DATA
{ GRAPH <http://example/bookStore> { <http://example/book1> dc:title "Fundamentals of Compiler Design" } }
</pre>
<p>Data before:</p>
<pre class="data"><strong># Graph: http://example/bookStore</strong>
@prefix dc: <http://purl.org/dc/elements/1.1/> .
<http://example/book1> dc:title "Fundamentals of Compiler Desing" .
</pre>
<p>Data after:</p>
<pre class="data"><strong># Graph: http://example/bookStore</strong>
@prefix dc: <http://purl.org/dc/elements/1.1/> .
<http://example/book1> dc:title "Fundamentals of Compiler Design" .
</pre>
</div>
<div class="div3">
<h4><a name="deleteInsert" id="deleteInsert"></a>3.1.3 DELETE/INSERT</h4>
<p>The <code><a href="#deleteInsert">DELETE/INSERT</a></code> operation can be used to remove or add triples from/to the Graph Store based on bindings for a query pattern specified in a
<code>WHERE</code> clause:</p>
<pre class="defn">( <strong>WITH</strong> <em><a href="http://www.w3.org/TR/sparql11-query/#rIRIREF">IRIref</a></em> )?
( ( <em><a href="http://www.w3.org/TR/sparql11-query/#rDeleteData">DeleteClause</a> <a href="http://www.w3.org/TR/sparql11-query/#rInsertData">InsertClause</a></em>? ) | <em><a href=
"http://www.w3.org/TR/sparql11-query/#rInsertData">InsertClause</a></em> )
( <strong>USING ( NAMED )?</strong> <em><a href="http://www.w3.org/TR/sparql11-query/#rIRIREF">IRIref</a></em> )*
<strong>WHERE</strong> <em><a href="http://www.w3.org/TR/sparql11-query/#rGroupGraphPattern">GroupGraphPattern</a></em></pre>
<p>The <em>DeleteClause</em> and <em>InsertClause</em> forms can be broken down as follows:</p>
<pre class="defn" id="delete_insert_clause"><em>DeleteClause</em> ::= <strong>DELETE </strong> <code><em><a href=
"http://www.w3.org/TR/sparql11-query/#rQuadPattern">QuadPattern</a></em></code>
<em>InsertClause</em> ::= <strong>INSERT </strong> <code><em><a href="http://www.w3.org/TR/sparql11-query/#rQuadPattern">QuadPattern</a></em></code>
</pre>
<p>This operation identifies data with the <code>WHERE</code> clause, which will be used to compute solution sequences of bindings for a set of variables. The bindings for each solution are
then substituted into the <code>DELETE</code> template to remove triples, and then in the <code>INSERT</code> template to create new triples. If any solution produces a triple containing an
unbound variable or an illegal RDF construct, such as a literal in a subject or predicate position, then that triple is not included when processing the operation: <code>INSERT</code> will
not instantiate new data in the output graph, and <code>DELETE</code> will not remove anything. The graphs used for computing a solution sequence may be different to the graphs modified
with the <code>DELETE</code> and <code>INSERT</code> templates.</p>
<p>The <code>WITH</code> clause defines the graph that will be modified or matched against for any of the subsequent elements (in <code>DELETE</code>, <code>INSERT</code>, or
<code>WHERE</code> clauses) if they do not specify a graph explicitly. If not provided, then the default graph of the Graph Store (or an explicitly declared dataset in the
<code>WHERE</code> clause) will be assumed. That is, a <code>WITH</code> clause may be viewed as syntactic sugar for wrapping both the <code><em>QuadPattern</em></code>s in subsequent
<code>DELETE</code> and <code>INSERT</code> clauses, and likewise the <code><em>GroupGraphPattern</em></code> in the subsequent <code>WHERE</code> clause into <code>GRAPH</code> patterns.
This can be used to avoid refering to the same graph multiple times in a single operation.</p>
<p>Following the optional <code>WITH</code> clause are the <code>INSERT</code> and/or <code>DELETE</code> clauses. The deletion of the triples happens before the insertion. The pattern in
the <code>WHERE</code> clause is evaluated only once, before the delete part of the operation is performed. The overall processing model is that the pattern is executed, the results used to
instantiate the <code>DELETE</code> template, the deletes performed, the results used again to instantiate the <code>INSERT</code> template, and the inserts performed.</p>
<p>If the <code>DELETE</code> clause is omitted, then the operation only inserts data (see <code><a href="#insert">INSERT</a></code>). If the <code>INSERT</code> clause is omitted, then the
operation only removes data (see <code><a href="#delete">DELETE</a></code>). The grammar does not permit both <code>DELETE</code> and <code>INSERT</code> to be omitted in the same
operation.</p>
<p>The <code><span class="doc-ref" id="defUSING">USING</span></code> and
<code><span class="doc-ref" id="defUSINGNAMED">USING NAMED</span></code> clauses affect the <a href="http://www.w3.org/TR/sparql11-query/#rdfDataset">RDF Dataset</a> used while
evaluating the <code>WHERE</code> clause. This describes a dataset in the same way as <code>FROM</code> and <code>FROM NAMED</code> clauses describe <a href=
"http://www.w3.org/TR/sparql11-query/#specifyingDataset">RDF Datasets in the SPARQL 1.1 Query Language</a>. The keyword <code>USING</code> instead of <code>FROM</code> in update requests is
to avoid possible ambiguities which could arise from writing "<code>DELETE FROM</code>". That is, the <a href=
"http://www.w3.org/TR/sparql11-query/#rGroupGraphPattern"><code><em>GroupGraphPattern</em></code></a> in the <code>WHERE</code> clause will be matched against the dataset described by
explicit <code>USING</code> or <code>USING NAMED</code> clauses, if specified, and against the Graph Store otherwise.</p>
<p>The <code>WITH</code> clause provides a convenience for when an operation primarily refers to a single graph. If a graph name is specified in a <code>WITH</code> clause, then - for the
purposes of evaluating the <code>WHERE</code> clause - this will define an RDF Dataset containing a default graph with the specified name, but only in the absence of <code>USING</code> or
<code>USING NAMED</code> clauses. In the presence of one or more graphs referred to in <code>USING</code> clauses and/or <code>USING NAMED</code> clauses, the <code>WITH</code> clause will
be ignored while evaluating the <code>WHERE</code> clause.</p>
<p>The <a href="http://www.w3.org/TR/sparql11-query/#rGroupGraphPattern"><code><em>GroupGraphPattern</em></code></a> in the <code>WHERE</code> clause is evaluated as in a SPARQL query
"<code>SELECT * WHERE <em>GroupGraphPattern</em></code>" and all the solution bindings are applied to the preceding <code>DELETE</code> and <code>INSERT</code> templates for defining the
triples to be deleted from or inserted into the Graph Store.</p>
<p>Again, <code><em>QuadPattern</em></code>s are formed by <code><em><a href="http://www.w3.org/TR/sparql11-query/#rTriplesTemplate">TriplesTemplate</a></em></code>s, i.e., sets of triple
patterns, optionally wrapped into a <code>GRAPH</code> block, where the <code>GRAPH</code> clause indicates the named graph in the Graph Store to be updated; on any
<code><em>TripleTemplate</em></code>s without a <code>GRAPH</code> clause, the <code>INSERT</code> or <code>DELETE</code> clauses applies to the graph specified by the <code>WITH</code>
clause, or the default graph of the Graph Store if no <code>WITH</code> clause is present.</p>
<p>To illustrate the use of the <code>WITH</code> clause, an operation of the general form:</p>
<pre class="query">WITH <g1> DELETE { a b c } INSERT { x y z } WHERE { ... }</pre>
<p>is considered equivalent to:</p>
<pre class="query">DELETE { GRAPH <g1> { a b c } } INSERT { GRAPH <g1> { x y z } } USING <g1> WHERE { ... }</pre>
<p>Note that explicit <code>GRAPH</code> clauses override a <code>WITH</code> clause. <code>WITH</code> provides a fallback to specify a graph (different from the default graph) to use when
one is not explicitly stipulated via <code>GRAPH</code>.</p>
<p>Deleting triples that are not present, or from a graph that is not present will have no effect and will result in <em>success</em>. Blank nodes are prohibited in a <code>DELETE</code>
template, since using a new blank node in a <code>DELETE</code> template would lead to nothing being deleted, as a new blank node cannot match anything in the Graph Store. It should be
noted that this restriction is not in the EBNF for the <a href="http://www.w3.org/TR/sparql11-query/#rDeleteClause"><code><em>DeleteClause</em></code></a> itself, but made explicit in Note
9 to the <a href="http://www.w3.org/TR/sparql11-query/#sparqlGrammar">grammar</a>.</p>
<p>If an operation tries to insert into a graph that does not exist, then that graph <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em> be created; again, there may be
implementations providing an update service over a fixed set of graphs which in such case <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> return with failure for update
requests that would create an unallowed graph. If no data is to be inserted, then no graph will be created. Particularly, note that</p>
<pre class="query">INSERT ... { GRAPH <g> {} } ...</pre>
<p>does not create <g>. If a user intends to create a graph regardless of the data to be inserted, then the graph management operations (<code><a href=
"#create">CREATE</a></code>/<code><a href="#create">LOAD</a></code>) may be used prior to any insertion operations.</p>
<p>Blank nodes that appear in an <code>INSERT</code> clause operate similarly to blank nodes in the template of a <code>CONSTRUCT</code> query, i.e., they are re-instantiated for any
solution of the <code>WHERE</code> clause; refer to <a href="http://www.w3.org/TR/sparql11-query/#templatesWithBNodes">Templates with Blank Nodes</a> in SPARQL Query 1.1 and to the <a href=
"#def_deleteinsertoperation">formal semantics of DELETE/INSERT</a> below for details. Blank nodes in the <code>WHERE</code> clause match data in the same way as for any SPARQL Query.</p>
<p><strong>Example 5:</strong></p>
<p><a name="example_5" id="example_5"></a>An example to update the graph <code>http://example/addresses</code> to rename all people with the given name "Bill" to "William".</p>
<pre class="query">PREFIX foaf: <http://xmlns.com/foaf/0.1/>
WITH <http://example/addresses>
DELETE { ?person foaf:givenName 'Bill' }
INSERT { ?person foaf:givenName 'William' }
WHERE
{ ?person foaf:givenName 'Bill'
} </pre>
<p>Data before:</p>
<pre class="data"><strong># Graph: http://example/addresses</strong>
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://example/president25> foaf:givenName "Bill" .
<http://example/president25> foaf:familyName "McKinley" .
<http://example/president27> foaf:givenName "Bill" .
<http://example/president27> foaf:familyName "Taft" .
<http://example/president42> foaf:givenName "Bill" .
<http://example/president42> foaf:familyName "Clinton" .</pre>
<p>Data after:</p>
<pre class="data"><strong># Graph: http://example/addresses</strong>
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://example/president25> foaf:givenName "William" .
<http://example/president25> foaf:familyName "McKinley" .
<http://example/president27> foaf:givenName "William" .
<http://example/president27> foaf:familyName "Taft" .
<http://example/president42> foaf:givenName "William" .
<http://example/president42> foaf:familyName "Clinton" .
</pre>
<div class="div4">
<h5><a name="delete" id="delete"></a>3.1.3.1 DELETE (Informative)</h5>
<pre class="defn">( <strong>WITH</strong> <em><a href="http://www.w3.org/TR/sparql11-query/#rIRIREF">IRIref</a></em> )?
<strong>DELETE </strong> <code><em><a href="http://www.w3.org/TR/sparql11-query/#rQuadPattern">QuadPattern</a></em></code>
( <strong>USING ( NAMED )?</strong> <em><a href="http://www.w3.org/TR/sparql11-query/#rIRIREF">IRIref</a></em> )*
<strong>WHERE</strong> <em><a href="http://www.w3.org/TR/sparql11-query/#rGroupGraphPattern">GroupGraphPattern</a></em>
</pre>
<p>The <code>DELETE</code> operation is a form of the <a href="#deleteInsert"><code>DELETE/INSERT</code></a> operation having no <code>INSERT</code> section. A compliant implementation of
<code>DELETE/INSERT</code> will already implement this operation correctly. The <code>DELETE</code> operation is described here separately for clarity. Analogous to <a href=
"#deleteInsert"><code>DELETE/INSERT</code></a>, deleting triples that are not present, or from a graph that is not present will have no effect and will result in success.</p>
<p>If any <code>DELETE</code> template specifies a <code>GRAPH</code> then this will be the graph affected. Otherwise, the operation will be applied to the graph specified in the
<code>WITH</code> clause, if one was specified, or the default graph otherwise.</p>
<p>The <code>WHERE</code> clause identifies data in existing graphs, and creates bindings to be used by the template. The graphs to apply the <em>GroupGraphPattern</em> follow the same
rules as for <code>DELETE/INSERT</code>.</p>
<p><strong>Example 6:</strong></p>
<p><a name="example_6" id="example_6"></a>This example request deletes all records of old books (with date before year 1970) from the store's default graph:</p>
<pre class="query">PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
DELETE
{ ?book ?p ?v }
WHERE
{ ?book dc:date ?date .
FILTER ( ?date > "1970-01-01T00:00:00-02:00"^^xsd:dateTime )
?book ?p ?v
}</pre>
<p>The pattern in <code>WHERE</code> is matched against the Graph Store. The resulting sequence of solutions to the WHERE clause is used to instantiate the triple patterns in the
<code>DELETE</code> template similar to CONSTRUCT in SPARQL 1.1 Query. The resulting triples are then removed from the Graph Store.</p>
<p>Data before:</p>
<pre class="data"><strong># Default graph</strong>
@prefix dc: <http://purl.org/dc/elements/1.1/> .
<http://example/book1> dc:title "Principles of Compiler Design" .
<http://example/book1> dc:date "1977-01-01T00:00:00-02:00"^^xsd:dateTime .
<http://example/book2> ns:price 42 .
<http://example/book2> dc:title "David Copperfield" .
<http://example/book2> dc:creator "Edmund Wells" .
<http://example/book2> dc:date "1948-01-01T00:00:00-02:00"^^xsd:dateTime .
<http://example/book3> dc:title "SPARQL 1.1 Tutorial" .</pre>
<p>Data after:</p>
<pre class="data"><strong># Default graph</strong>
@prefix dc: <http://purl.org/dc/elements/1.1/> .
<http://example/book2> ns:price 42 .
<http://example/book2> dc:title "David Copperfield" .
<http://example/book2> dc:creator "Edmund Wells" .
<http://example/book2> dc:date "1948-01-01T00:00:00-02:00"^^xsd:dateTime .
<http://example/book3> dc:title "SPARQL 1.1 Tutorial" .</pre>
<p><strong>Example 7:</strong></p>
<p><a name="example_7" id="example_7"></a>This example request removes all statements about anything with a given name of "Fred" from the graph <code>http://example/addresses</code>. A
<code>WITH</code> clause is present, meaning that graph <code>http://example/addresses</code> is both the one from which triples are being removed and the one which the <code>WHERE</code>
clause is matched against.</p>
<pre class="query">PREFIX foaf: <http://xmlns.com/foaf/0.1/>
WITH <http://example/addresses>
DELETE { ?person ?property ?value }
WHERE { ?person ?property ?value ; foaf:givenName 'Fred' }
</pre>
<p>Data before:</p>
<pre class="data"><strong># Graph: http://example/addresses</strong>
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://example/william> a foaf:Person .
<http://example/william> foaf:givenName "William" .
<http://example/william> foaf:mbox <mailto:bill@example> .
<http://example/fred> a foaf:Person .
<http://example/fred> foaf:givenName "Fred" .
<http://example/fred> foaf:mbox <mailto:fred@example> .</pre>
<p>Data after:</p>
<pre class="data"><strong># Graph: http://example/addresses</strong>
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://example/william> a foaf:Person .
<http://example/william> foaf:givenName "William" .
<http://example/william> foaf:mbox <mailto:bill@example> .</pre>
<p>Another example of <code>DELETE</code> is provided in the <a href="#example_9">final example</a> in the following section which demonstrates multiple operations combining an
<code>INSERT</code> with a <code>DELETE</code>.</p>
</div>
<div class="div4">
<h5><a name="insert" id="insert"></a>3.1.3.2 INSERT (Informative)</h5>
<pre class="defn">( <strong>WITH</strong> <em><a href="http://www.w3.org/TR/sparql11-query/#rIRIREF">IRIref</a></em> )?
<strong>INSERT </strong> <code><em><a href="http://www.w3.org/TR/sparql11-query/#rQuadPattern">QuadPattern</a></em></code>
( <strong>USING ( NAMED )?</strong> <em><a href="http://www.w3.org/TR/sparql11-query/#rIRIREF">IRIref</a></em> )*
<strong>WHERE</strong> <em><a href="http://www.w3.org/TR/sparql11-query/#rGroupGraphPattern">GroupGraphPattern</a></em>
</pre>
<p>The <code>INSERT</code> operation is a form of the <a href="#deleteInsert"><code>DELETE/INSERT</code></a> operation having no <code>DELETE</code> section. A compliant implementation of
<code>DELETE/INSERT</code> will already implement this operation correctly. The <code>INSERT</code> operation is described here separately for clarity.</p>
<p>If the <code>INSERT</code> template specifies <code>GRAPH</code> blocks then these will be the graphs affected. Otherwise, the operation will be applied to the default graph, or,
respectively, to the graph specified in the <code>WITH</code> clause, if one was specified. If no <code>USING (NAMED)</code> clause is present, then the pattern in the <code>WHERE</code>
clause will be matched against the Graph Store, otherwise against the dataset specified by the <code>USING (NAMED)</code> clauses. The matches against the <code>WHERE</code> clause create
bindings to be applied to the template for determining triples to be inserted (following the same rules as for <a href="#deleteInsert"><code>DELETE/INSERT</code></a>).</p>
<p>If any instantiation arising from the solution sequence produces a triple containing an unbound variable or an illegal RDF construct, such as a literal in subject or predicate
position, then that triple is not inserted. The template can contain triples with no variables (known as ground or explicit triples), and these will also be inserted, provided that the
solution sequence is not empty.</p>
<p><strong>Example 8:</strong></p>
<p><a name="example_8" id="example_8"></a>This example copies triples from one named graph to another named graph based on a pattern:</p>
<pre class="query">PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
INSERT
{ GRAPH <http://example/bookStore2> { ?book ?p ?v } }
WHERE
{ GRAPH <http://example/bookStore>
{ ?book dc:date ?date .
FILTER ( ?date > "1970-01-01T00:00:00-02:00"^^xsd:dateTime )
?book ?p ?v
} } </pre>
<p>Data before:</p>
<pre class="data"><strong># Graph: http://example/bookStore</strong>
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://example/book1> dc:title "Fundamentals of Compiler Design" .
<http://example/book1> dc:date "1977-01-01T00:00:00-02:00"^^xsd:dateTime .
<http://example/book2> ns:price 42 .
<http://example/book2> dc:title "David Copperfield" .
<http://example/book2> dc:creator "Edmund Wells" .
<http://example/book2> dc:date "1948-01-01T00:00:00-02:00"^^xsd:dateTime .
<http://example/book3> dc:title "SPARQL 1.1 Tutorial" .</pre>
<pre class="data"><strong># Graph: http://example/bookStore2</strong>
@prefix dc: <http://purl.org/dc/elements/1.1/> .
<http://example/book4> dc:title "SPARQL 1.0 Tutorial" .</pre>
<p>Data after:</p>
<pre class="data"><strong># Graph: http://example/bookStore</strong>
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://example/book1> dc:title "Fundamentals of Compiler Design" .
<http://example/book1> dc:date "1977-01-01T00:00:00-02:00"^^xsd:dateTime .
<http://example/book2> ns:price 42 .
<http://example/book2> dc:title "David Copperfield" .
<http://example/book2> dc:creator "Edmund Wells" .
<http://example/book2> dc:date "1948-01-01T00:00:00-02:00"^^xsd:dateTime .
<http://example/book3> dc:title "SPARQL 1.1 Tutorial" .</pre>
<pre class="data"><strong># Graph: http://example/bookStore2</strong>
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<http://example/book1> dc:title "Fundamentals of Compiler Design" .
<http://example/book1> dc:date "1977-01-01T00:00:00-02:00"^^xsd:dateTime .
<http://example/book4> dc:title "SPARQL 1.0 Tutorial" .</pre>
<p><strong>Example 9:</strong></p>
<p><a name="example_9" id="example_9"></a>This example copies triples of name and email from one named graph to another. Some individuals may not have an address, but the name is copied
regardless:</p>
<pre class="query">PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
INSERT
{ GRAPH <http://example/addresses>
{
?person foaf:name ?name .
?person foaf:mbox ?email
} }
WHERE
{ GRAPH <http://example/people>
{
?person foaf:name ?name .
OPTIONAL { ?person foaf:mbox ?email }
} }</pre>
<p>Data before:</p>
<pre class="data"><strong># Graph: http://example/people</strong>
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdf: >http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
_:a rdf:type foaf:Person .
_:a foaf:name "Alice" .
_:a foaf:mbox <mailto:[email protected]> .
_:b rdf:type foaf:Person .
_:b foaf:name "Bob" .</pre>
<pre class="data"><strong># Graph: http://example/addresses</strong>
@prefix foaf: <http://xmlns.com/foaf/0.1/> .</pre>
<p>Data after:</p>
<pre class="data"><strong># Graph: http://example/people</strong>
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdf: >http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
_:a rdf:type foaf:Person .
_:a foaf:name "Alice" .
_:a foaf:mbox <mailto:[email protected]> .
_:b rdf:type foaf:Person .
_:b foaf:name "Bob" .</pre>
<pre class="data"><strong># Graph: http://example/addresses</strong>
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
_:a foaf:name "Alice" .
_:a foaf:mbox <mailto:[email protected]> .
_:b foaf:name "Bob" .</pre>
<p><strong>Example 10:</strong></p>
<p><a name="example_10" id="example_10"></a>This example request first copies triples from one named graph to another named graph based on a pattern; triples about all the copied objects
that are classified as Physical Objects are then deleted. This demonstrates two operations in a single request, both of which share common <code>PREFIX</code> definitions.</p>
<pre class="query">PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX dcmitype: <http://purl.org/dc/dcmitype/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
INSERT
{ GRAPH <http://example/bookStore2> { ?book ?p ?v } }
WHERE
{ GRAPH <http://example/bookStore>
{ ?book dc:date ?date .
FILTER ( ?date < "2000-01-01T00:00:00-02:00"^^xsd:dateTime )
?book ?p ?v
}
} ;
WITH <http://example/bookStore>
DELETE
{ ?book ?p ?v }
WHERE
{ ?book dc:date ?date ;
dc:type dcmitype:PhysicalObject .
FILTER ( ?date < "2000-01-01T00:00:00-02:00"^^xsd:dateTime )
?book ?p ?v
}
</pre>
<p>Data before:</p>
<pre class="data"><strong># Graph: http://example/bookStore</strong>
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dcmitype: <http://purl.org/dc/dcmitype/> .
<http://example/book1> dc:title "Fundamentals of Compiler Design" .
<http://example/book1> dc:date "1996-01-01T00:00:00-02:00"^^xsd:dateTime .
<http://example/book1> a dcmitype:PhysicalObject .
<http://example/book3> dc:title "SPARQL 1.1 Tutorial" .</pre>
<pre class="data"><strong># Graph: http://example/bookStore2</strong>
@prefix dc: <http://purl.org/dc/elements/1.1/> .
<http://example/book4> dc:title "SPARQL 1.0 Tutorial" .</pre>
<p>Data after:</p>
<pre class="data"><strong># Graph: http://example/bookStore</strong>
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dcmitype: <http://purl.org/dc/dcmitype/> .
<http://example/book3> dc:title "SPARQL 1.1 Tutorial" .</pre>
<pre class="data"><strong># Graph: http://example/bookStore2</strong>
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix dcmitype: <http://purl.org/dc/dcmitype/> .
<http://example/book1> dc:title "Fundamentals of Compiler Design" .
<http://example/book1> dc:date "1996-01-01T00:00:00-02:00"^^xsd:dateTime .
<http://example/book1> a dcmitype:PhysicalObject .
<http://example/book4> dc:title "SPARQL 1.0 Tutorial" .</pre>
</div>
<div class="div4">
<h5><a name="deleteWhere" id="deleteWhere"></a>3.1.3.3 DELETE WHERE</h5>
<pre class="defn"><strong>DELETE WHERE </strong> <code><em><a href="http://www.w3.org/TR/sparql11-query/#rQuadPattern">QuadPattern</a></em></code>
</pre>
<p>The <code>DELETE WHERE</code> operation is a shortcut form for the <a href="#deleteInsert"><code>DELETE/INSERT</code></a> operation where bindings matched by the <code>WHERE</code>
clause are used to define the triples in a graph that will be deleted. Analogous to <code>DELETE/INSERT</code>, deleting triples that are not present, or from a graph that is not present
will have no effect and will result in success.</p>
<p>The <code><em><a href="http://www.w3.org/TR/sparql11-query/#rQuadPattern">QuadPattern</a></em></code> is used both as a pattern for matching against triples and graphs, and as the
template for deletion. If any <code><em>TripleTemplate</em></code>s within the <code><em><a href="http://www.w3.org/TR/sparql11-query/#rQuadPattern">QuadPattern</a></em></code> appear in
the scope of a <code>GRAPH</code> clause then this will determine the graph that that template is matched on, and also the graph from which any matching triples will be removed. Any
<code><em>TripleTemplate</em></code>s not in the scope of a <code>GRAPH</code> clause will be matched against/removed from the default graph.</p>
<p><strong>Example 11:</strong></p>
<p><a name="example_11" id="example_11"></a>This example request removes all statements about anything with a given name of "Fred" from the default graph:</p>
<pre class="query">PREFIX foaf: <http://xmlns.com/foaf/0.1/>
DELETE WHERE { ?person foaf:givenName 'Fred';
?property ?value }
</pre>
<p>Data before:</p>
<pre class="data"><strong># Default graph</strong>
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://example/william> a foaf:Person .
<http://example/william> foaf:givenName "William" .
<http://example/william> foaf:mbox <mailto:bill@example> .
<http://example/fred> a foaf:Person .
<http://example/fred> foaf:givenName "Fred" .
<http://example/fred> foaf:mbox <mailto:fred@example> .</pre>
<p>Data after:</p>
<pre class="data"><strong># Default graph</strong>
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://example/william> a foaf:Person .
<http://example/william> foaf:givenName "William" .
<http://example/william> foaf:mbox <mailto:bill@example> .</pre>
<p><strong>Example 12:</strong></p>
<p><a name="example_12" id="example_12"></a>This example request removes both statements naming some resource "Fred" in the graph <code>http://example.com/names</code>, and also
statements about that resource from the graph <code>http://example/addresses</code> (assuming that some of the resources in the graph <code>http://example.com/names</code> have
corresponding triples in the graph <code>http://example/addresses</code>).</p>
<pre class="query">PREFIX foaf: <http://xmlns.com/foaf/0.1/>
DELETE WHERE {
GRAPH <http://example.com/names> {
?person foaf:givenName 'Fred' ;
?property1 ?value1
}
GRAPH <http://example.com/addresses> {
?person ?property2 ?value2
}
}
</pre>
<pre class="data"><strong># Graph: http://example.com/names</strong>
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://example/william> a foaf:Person .
<http://example/william> foaf:givenName "William" .
<http://example/fred> a foaf:Person .
<http://example/fred> foaf:givenName "Fred" .</pre>
<pre class="data"><strong># Graph: http://example.com/addresses</strong>
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://example/william> foaf:mbox <mailto:bill@example> .
<http://example/fred> foaf:mbox <mailto:fred@example> .</pre>
<p>Data after:</p>
<pre class="data"><strong># Graph: http://example.com/names</strong>
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://example/william> a foaf:Person .
<http://example/william> foaf:givenName "William" .
</pre>
<pre class="data"><strong># Graph: http://example.com/addresses</strong>
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
<http://example/william> foaf:mbox <mailto:bill@example> .</pre>
</div>
</div>
<div class="div3">
<h4><a name="load" id="load"></a>3.1.4 LOAD</h4>
<p>The <code>LOAD</code> operation reads an RDF document from a IRI and inserts its triples into the specified graph in the Graph Store. The specified destination graph <em class="rfc2119"
title="Keyword in RFC 2119 context">SHOULD</em> be created if required; again, implementations providing an update service over a fixed set of graphs <em class="rfc2119" title=
"Keyword in RFC 2119 context">MUST</em> return with failure for a request that would create a disallowed graph. If the destination graph already exists, then no data in that graph will be
removed.</p>
<pre class="defn"><strong>LOAD</strong> ( <strong>SILENT</strong> )? <em><a href=
"http://www.w3.org/TR/sparql11-query/#rIRIREF">IRIref_from</a></em> ( <strong>INTO GRAPH</strong> <em><a href="http://www.w3.org/TR/sparql11-query/#rIRIREF">IRIref_to</a></em> )?</pre>
<p><em>IRIref_from</em> specifies the IRI of a document such that a store will be able to identify, locate and read the document. The most common form will be URLs with the <em>http</em>
IRI schemes. Once the document has been read, the resulting triples will be inserted into the destination graph named by the IRI referred to by <em>IRIref_to</em>.</p>
<p>If no destination graph IRI (<em>IRIref_to</em>) is provided to load the triples into, then the data will be loaded into the default graph.</p>
<p>In case no RDF data can be retrieved (as opposed to the empty graph being retrieved) from the IRI denoted by <em>IRIref_from</em>, or in case the retrieval method returns an error (such
as, for instance an HTTP error code), the SPARQL 1.1 Update service <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em> return failure and the status of the Graph Store
<em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em> remain in the same status as prior to the request; in case the keyword SILENT is present, however, the operation will
still return success and the status of the Graph Store is not specified by the present document: implementations may create the destination graph or not and partially load data, in case of
a transmission error where partial data has been received (which itself may be legal RDF).</p>
</div>
<div class="div3">
<h4><a name="clear" id="clear"></a>3.1.5 CLEAR</h4>
<p>The <code>CLEAR</code> operation removes all the triples in the specified graph(s) in the Graph Store.</p>
<pre class="defn"><strong>CLEAR</strong> ( <strong>SILENT</strong> )? (<strong>GRAPH</strong> <em><a href=
"http://www.w3.org/TR/sparql11-query/#rIRIREF">IRIref</a></em> | <strong>DEFAULT</strong> | <strong>NAMED</strong> | <strong>ALL</strong> )</pre>
<p>Here, the <code>DEFAULT</code> keyword is used to remove all triples in the default graph of the Graph Store, the <code>NAMED</code> keyword is used to remove all triples in all named
graphs of the Graph Store and the <code>ALL</code> keyword is used to remove all triples in all graphs of the Graph Store. The <code>GRAPH</code> keyword is used to remove all triples from
a graph denoted by <code><em>IRIref</em></code>. This operation is not required to remove the empty graphs from the Graph Store, but an implementation <em class="rfc2119" title=
"Keyword in RFC 2119 context">MAY</em> decide to do so.</p>
<pre class="defn"># Remove all triples from a specified graph.
<strong>CLEAR GRAPH</strong> <em>IRIref</em> </pre>
<p>in principle has the same effect as:</p>
<pre class="defn"># Remove all triples from the graph named with the IRI denoted by <em>IRIref</em>.
<strong>DELETE</strong> { <strong>GRAPH</strong> <em>IRIref</em> { ?s ?p ?o } } <strong>WHERE</strong> { <strong>GRAPH</strong> <em>IRIref</em> { ?s ?p ?o } }</pre>
<div class="note">
<p class="prefix"><strong>Note:</strong></p>For services which form the default graph from the union of other graphs, <code>CLEAR DEFAULT</code> may have further implications which we
leave unspecified here.
</div>
<p>If the store records the existence of empty graphs, then the SPARQL 1.1 Update service, by default, <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em> return
<em>failure</em> if the specified graph does not exist. If <code>SILENT</code> is present, the result of the operation will always be success.</p>
<p>Stores that do not record empty graphs will always return <em>success</em>.</p>
</div>
</div>
<div class="div2">
<h3><a name="graphManagement" id="graphManagement"></a>3.2 Graph Management</h3>
<p>Graph management operations allow creating, destroying, moving and copying named graphs in the Graph Store, or adding the contents of one graph to another. Operations for creation and
destruction are not required to result in any actions, since Graph Stores are not required to record the existence of empty named graphs.</p>
<p>The default graph in a Graph Store always exists.</p>
<p>SPARQL 1.1 Update provides these graph management operations:</p>
<ul>
<li>The <code><a href="#create">CREATE</a></code> operation creates a new graph in stores that support empty graphs.</li>
<li>The <code><a href="#drop">DROP</a></code> operation removes a graph and all of its contents.</li>
<li>The <code><a href="#copy">COPY</a></code> operation modifies a graph to contain a copy of another.</li>
<li>The <code><a href="#move">MOVE</a></code> operation moves all of the data from one graph into another.</li>
<li>The <code><a href="#add">ADD</a></code> operation reproduces all data from one graph into another.</li>
</ul>
<div class="div3">
<h4><a name="create" id="create"></a>3.2.1 CREATE</h4>
<p>This operation creates a graph in the Graph Store:</p>
<pre class="defn"><strong>CREATE</strong> ( <strong>SILENT</strong> )? <strong>GRAPH</strong> <em><a href="http://www.w3.org/TR/sparql11-query/#rIRIREF">IRIref</a></em></pre>
<p>For stores that record empty graphs, this will create a new empty graph in the store with a name specified by the IRI. If the graph already exists, then a <em>failure</em> <em class=
"rfc2119" title="Keyword in RFC 2119 context">SHOULD</em> be returned, except when the <code>SILENT</code> keyword is used; in either case, the contents of already existing graphs remain
unchanged. If the graph may not be created, then a <em>failure</em> <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be returned, except when the <code>SILENT</code>
keyword is used.</p>
<p>Stores that do not record empty named graphs will always return <em>success</em> on creation of a non-existing graph.</p>
</div>
<div class="div3">
<h4><a name="drop" id="drop"></a>3.2.2 DROP</h4>
<pre class="query"><strong>DROP</strong> ( <strong>SILENT</strong> )? (<strong>GRAPH</strong> <em><a href=
"http://www.w3.org/TR/sparql11-query/#rIRIREF">IRIref</a></em> | <strong>DEFAULT</strong> | <strong>NAMED</strong> | <strong>ALL</strong> )</pre>
<p>The <code>DROP</code> operation removes the specified graph(s) from the Graph Store. The <code>GRAPH</code> keyword is used to remove a graph denoted by <code><em>IRIref</em></code>, the
<code>DEFAULT</code> keyword is used to remove the default graph from the Graph Store, the <code>NAMED</code> keyword is used to remove all named graphs from the Graph Store, and the
<code>ALL</code> keyword is used to remove all graphs from the Graph Store, i.e., resetting the store. After successful completion of this operation, the specified graphs are no longer
available for further graph update operations. However, in case the <code>DEFAULT</code> graph of the Graph Store is dropped, implementations <em class="rfc2119" title=
"Keyword in RFC 2119 context">MUST</em> restore it after it was removed, i.e., <code>DROP DEFAULT</code> is equivalent to <code><a href="#clear">CLEAR DEFAULT</a></code>.</p>
<p>If the store records the existence of empty graphs, then the SPARQL 1.1 Update service, by default, <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em> return
<em>failure</em> if the specified named graph does not exist. If <code>SILENT</code> is present, the result of the operation will always be success.</p>
<p>Stores that do not record empty graphs will always return <em>success</em>.</p>
</div>
<div class="div3">
<h4><a name="copy" id="copy"></a>3.2.3 COPY</h4>
<p>The <code>COPY</code> operation is a shortcut for inserting all data from an input graph into a destination graph. Data from the input graph is not affected, but data from the
destination graph, if any, is removed before insertion.</p>
<pre class="query"><strong>COPY</strong> ( <strong>SILENT</strong> )? ( ( <strong>GRAPH</strong> )? <em><a href=
"http://www.w3.org/TR/sparql11-query/#rIRIREF">IRIref_from</a></em> | <strong>DEFAULT</strong>) <strong>TO</strong> ( ( <strong>GRAPH</strong> )? <em><a href=
"http://www.w3.org/TR/sparql11-query/#rIRIREF">IRIref_to</a></em> | <strong>DEFAULT</strong> )</pre>
<p>is similar in operation to:</p>
<pre class="query"><strong>DROP</strong> <strong>SILENT</strong> (<strong>GRAPH</strong> <em><a href=
"http://www.w3.org/TR/sparql11-query/#rIRIREF">IRIref_to</a></em> | <strong>DEFAULT</strong>);
<strong>INSERT</strong> { ( <strong>GRAPH</strong> <em><a href=
"http://www.w3.org/TR/sparql11-query/#rIRIREF">IRIref_to</a></em> )? <strong>{ ?s ?p ?o } } WHERE</strong> { ( <strong>GRAPH</strong> <em><a href=
"http://www.w3.org/TR/sparql11-query/#rIRIREF">IRIref_from</a></em> )? <strong>{ ?s ?p ?o } }</strong></pre>
<p>The difference between <code>COPY</code> and the <code>DROP/INSERT</code> combination is that if <code>COPY</code> is used to copy a graph onto itself then no operation will be performed
and the data will be left as it was. Using <code>DROP/INSERT</code> in this situation would result in an empty graph.</p>
<p>If the destination graph does not exist, it will be created. By default, the service <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em> return <em>failure</em> if the input
graph does not exist. If <code>SILENT</code> is present, the result of the operation will always be success.</p>
<p><strong>Example 13:</strong></p>
<p><a name="example_13" id="example_13"></a>This example request copies all statements from the default graph to a named graph:</p>
<pre class="query">COPY DEFAULT TO <http://example.org/named></pre>
<p>Data before:</p>
<pre class="data"><strong># Default graph</strong>
@prefix foaf: <http://xmlns.com/foaf/0.1/> .