graph
How to create, truncate, or drop a graph.
This command is used to create a new graph, truncate an existing graph, or drop an existing graph. A graph can also be convert from an existing non-graph Cassandra keyspace.
Synopsis
system.graph('graph_name'). [ifNotExists(). | ifExists().] [withReplication("{'class': 'NetworkTopologyStrategy', 'data_center_name': replication_factor}").] [andDurableWrites( true | false ).] [fromExistingKeyspace().] create() | truncate() | drop() | exists()
- ifNotExists, ifExists
- Creating a graph can check for lack of current existence with
ifNotExists()
before creating a graph. Truncating and dropping a graph can check for existence withifExists()
before attempting the operations. - withReplication
-
Set replication class and replication factor for each datacenter using the same guidelines as for CQL keyspaces.Important: The replication factor cannot be altered once set for the graph, just as the replication factor for a keyspace cannot be changed.
DSE database settings for replication factor are used, either
SimpleStrategy
for single datacenters orNetworkTopologyStrategy
for multiple datacenters. The default replication strategy for a multi-datacenter graph isNetworkTopologyStrategy
, whereas for a single datacenter, the replication strategy will default toSimpleStrategy
.The system replication settings can be verified using thecqlsh
tool, running the CQL commandDESCRIBE keyspace food
command:DESCRIBE KEYSPACE food;
with a result:CREATE KEYSPACE food_system WITH replication = {'class': 'NetworkTopologyStrategy', 'dc1: '3', 'dc2' : 2 } AND durable_writes = true;
- andDurableWrites (true | false)
- Set to
true
by default. While the setting can be changed, it is NOT recommended to setandDurableWrites
tofalse
. - fromExistingKeyspace
- Convert an existing non-graph keyspace to a Core Engine Graph.
- create
-
Create a new graph. The graph_name specified is used to create two DSE database keyspaces, graph_name and graph_name_system, and can only contain alphanumeric and underscore characters.
- truncate
-
Truncate an existing graph using this command. All data will be removed from the graph.
- drop
-
Drop an existing graph using this command. All data and schema will be lost. For better performance, truncate a graph before dropping it.
- exists
-
Check existence of a graph using this command.
Examples
system.graph('food_simple').ifNotExists().create()The resulting list:
==> OKand is created with
NetworkTopologyStrategy
.andDurableWrites
if
desired:system.graph('food'). ifNotExists(). withReplication("{'class': 'NetworkTopologyStrategy', '<DC_NAME>': 1}"). andDurableWrites(true). create()
graph_name
keyspace.system.graph('food_cql_conversion'). fromExistingKeyspace(). create()
system.graph('food'). ifExists(). truncate()The resulting list:
==> OK
system.graph('food'). ifExists(). drop()The resulting list:
==> OK
system.graph('food').exists()The resulting list:
==> true