Skip to content
Developer Edition runs on one host and does not require a product license file. Need multi-host deployment or performance testing at scale? Explore Enterprise Edition

DROP GRAPH statement

The DROP GRAPH statement destroys a graph or temporary graph. You can destroy a graph in the schema of the current session or a specified schema.

Note

Since temporary graphs exist in memory cache, they are automatically destroyed when their hosting services exit.

Notes

When a DROP GRAPH statement is executed to destroy a graph, graph data is not immediately physically deleted from the Storage service (disk space remains occupied). Instead, the data is permanently deleted during subsequent RocksDB Compaction operations.

You can submit a COMPACT job to force the physical deletion of the data. The actual immediate deletion depends on the current level of the data in RocksDB's LSM-tree hierarchy.

Note

An operation involving a non-default schema or an object in it requires access to the schema, either implicitly or through an explicit USAGE grant, as well as the privilege required for the operation. The schema access check and the privilege check for the requested operation are independent; satisfying one does not satisfy the other. Schema access control does not apply to temporary graphs or built-in procedures and functions. For more information, see Schema access control.

Prerequisites

  • To drop a graph, you must either be the owner of the graph, be granted to perform the action DROP on the graph, or be granted to perform the action DROP ANY GRAPH on the corresponding schema. For more information, see Roles and privileges.
  • To drop a temporary graph, you must be the user with the role ADMIN or the owner of the temporary graph.

Syntax

drop_graph_statement
DROP PROPERTY GRAPH IF EXISTS schema_reference / graph_name temp_graph_name

drop_graph_statement ::=
    'DROP' 'PROPERTY'? 'GRAPH' ('IF EXISTS')? ((schema_reference '/')? graph_name | temp_graph_name)  

Parameters

IF EXISTS

This clause checks if the graph or temporary graph to be destroyed exists. If it does not exist, the graph or temporary graph is not destroyed and no exception is thrown.

If you do not specify this clause, an exception is thrown if the graph or temporary graph to be destroyed does not exist.

schema_reference

The reference to the path of the schema. It specifies the schema path of the graph to be destroyed here.

Both absolute and relative schema paths can be used in the statement. To drop a graph that resides outside the schema in the current session, the schema path must be specified. For information about setting and viewing the schema, see SESSION SET and SHOW CURRENT_SCHEMA.

graph_name

The name of the graph to be destroyed.

temp_graph_name

The name of the temporary graph to be destroyed. It must start with a number sign (#).

Examples

Destroy a graph in the current schema

DROP GRAPH movie

The preceding example destroys the graph movie introduced in Example dataset.

Destroy a graph in the specified schema

DROP GRAPH /default_schema/my_graph

The preceding example destroys the graph my_graph created in the Examples section of CREATE GRAPH.

Destroy a temporary graph

DROP GRAPH IF EXISTS #movie_temporary_graph

The preceding example destroys the temporary graph #movie_temporary_graph created in CREATE TEMPORARY GRAPH.