INSERT and INSERT DATA
The INSERT function inserts the specified graph or triple patterns into the database. The INSERT DATA function inserts specific triples into the database. INSERT DATA statements cannot include variables.
INSERT Syntax
Use the following syntax to insert data using graph and triple patterns. The syntax below inserts triples into the default graph:
INSERT { triple_patterns } WHERE { triple_patterns }
The following syntax inserts triples into a named graph. The WHERE clause specifies the named graph to find triple patterns.
INSERT { GRAPH <graph> { triple_patterns } } WHERE { GRAPH <graph> { triple_patterns } }
As an alternative, you can include one or more USING clauses to specify named graphs for the WHERE clause. USING acts like a FROM clause in a SELECT query.
INSERT { GRAPH <graph> { triple_patterns } } USING <graph> WHERE { triple_patterns }
INSERT DATA Syntax
Use the following syntax to insert specific triples with the INSERT DATA function.
INSERT DATA { triples }
Use the following syntax to insert specific triples into a graph with the INSERT DATA function.
INSERT DATA { GRAPH <graph> { triples } }
The GRAPH statement specifies the graph to insert the triples in. The triples that you list must include URIs, literal, values, or blank nodes. You cannot specify triple patterns with variables. For example, the query below uses INSERT DATA to add a new user to the sample tickit data set:
INSERT DATA { GRAPH <tickit> { <person0> <firstname> "Jay" . <person0> <lastname> "Stevens" . <person0> <state> "CA" . } }
The query below inserts a graph named "friends" using data from the tickit graph.
INSERT { GRAPH <friends> { ?person <friendOf> ?friend . } USING <tickit> WHERE { ?person <friend> ?friend . }