USE
The USE
clause determines which graph a query, or query part, is executed against.
It is supported for queries and schema commands.
Syntax
The USE
clause can only appear as the prefix of schema commands, or as the first clause of queries:
USE <graph>
<other clauses>
Where <graph>
refers to the name or alias of a database in the DBMS.
Composite database syntax
When running queries against a composite database, the USE
clause can also appear as the first clause of:
-
Union parts:
USE <graph> <other clauses> UNION USE <graph> <other clauses>
-
Subqueries:
CALL { USE <graph> <other clauses> }
In subqueries, a
USE
clause may appear as the second clause, if directly following an importingWITH
clause.
When executing queries against a composite database, the USE
clause must only refer to graphs that are part of the current composite database.
Examples
Query a graph
In this example it is assumed that the DBMS contains a database named myDatabase
:
USE myDatabase
MATCH (n) RETURN n
Query a composite database constituent graph
In this example it is assumed that the DBMS contains a composite database named myComposite
, which includes an alias named myConstituent
:
USE myComposite.myConstituent
MATCH (n) RETURN n
Query a composite database constituent graph dynamically
The built-in function graph.byName()
can be used in the USE
clause to resolve a constituent graph from a string value containing the qualified name of a constituent.
This example uses a composite database named myComposite
that includes an alias named myConstituent
:
USE graph.byName('myComposite.myConstituent')
MATCH (n) RETURN n
The argument can be any expression that evaluates to the name of a constituent graph - for example a parameter:
USE graph.byName($graphName)
MATCH (n) RETURN n
Was this page helpful?