apoc.export.cypher.schema

Procedure

apoc.export.cypher.schema(file STRING, config MAP<STRING, ANY>) - exports all schema indexes and constraints to Cypher statements.

This procedure is not considered safe to run from multiple threads. It is therefore not supported by the parallel runtime (introduced in Neo4j 5.13). For more information, see the Cypher Manual → Parallel runtime.

Signature

apoc.export.cypher.schema(file =  :: STRING, config = {} :: MAP) :: (file :: STRING, batches :: INTEGER, source :: STRING, format :: STRING, nodes :: INTEGER, relationships :: INTEGER, properties :: INTEGER, time :: INTEGER, rows :: INTEGER, batchSize :: INTEGER, cypherStatements :: STRING, nodeStatements :: STRING, relationshipStatements :: STRING, schemaStatements :: STRING, cleanupStatements :: STRING)

Input parameters

Name Type Default

file

STRING

config

MAP

{}

Output parameters

Name Type

file

STRING

batches

INTEGER

source

STRING

format

STRING

nodes

INTEGER

relationships

INTEGER

properties

INTEGER

time

INTEGER

rows

INTEGER

batchSize

INTEGER

cypherStatements

STRING

nodeStatements

STRING

relationshipStatements

STRING

schemaStatements

STRING

cleanupStatements

STRING

Usage Examples

The examples in this section are based on a database that has applied the following constraints:

CREATE CONSTRAINT personName FOR (person:Person)
REQUIRE person.name IS UNIQUE;

CREATE CONSTRAINT userId FOR (user:User)
REQUIRE user.id IS UNIQUE;
CALL apoc.export.cypher.schema()
YIELD format, time, cypherStatements
RETURN format, time, cypherStatements;
Table 1. Results
format time cypherStatements

"cypher"

1

":begin CREATE CONSTRAINT FOR (node:Person) REQUIRE (node.name) IS UNIQUE; CREATE CONSTRAINT FOR (node:User) REQUIRE (node.id) IS UNIQUE; :commit CALL db.awaitIndexes(300); "