USE
Introduction
The USE clause determines which graph a query, or query part, is executed against.
It is supported for queries and schema commands.
The USE clause can not be used together with the PERIODIC COMMIT clause.
|
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 of a database in the DBMS.
Fabric syntax
When running queries against a Fabric 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
USEclause may appear as the second clause, if directly following an importingWITHclause
When executing queries against a Fabric database, in addition to referring to databases in the DBMS, the <graph> may also refer to a graph mounted through the Fabric configuration.
For more information, see Operations Manual → Fabric.
Examples
Query a graph by name
In this example we assume that your DBMS contains a database named myDatabase:
USE myDatabase
MATCH (n) RETURN n
Query a Fabric graph by name
In this example we assume that we have configured a Fabric database called exampleFabricSetup.
The graph that we wish to query is named exampleDatabaseName:
USE exampleFabricSetup.exampleDatabaseName
MATCH (n) RETURN n
Query a Fabric graph by graph ID
This examples continues with a Fabric database called exampleFabricSetup.
The graph we wish to query is configured with the graph id 0, which is why we can refer to it using the built-in function graph() with the argument 0:
USE exampleFabricSetup.graph(0)
MATCH (n) RETURN n