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.


replication("{'class' : 'NetworkTopologyStrategy', 'data_center_name' : replication_factor, 'data_center_name' : replication_factor }").
systemReplication("{'class' : 'NetworkTopologyStrategy', 'data_center_name' : replication_factor, 'data_center_name' : replication_factor }").
[ifNotExists().] create() | [ifExists().]truncate() | [ifExists().]drop() | exists()
replication, systemReplication
DSE database settings for replication factor are used, either SimpleStrategy for single datacenters or NetworkTopologyStrategy for multiple datacenters. The default replication strategy for a multi-datacenter graph is NetworkTopologyStrategy, whereas for a single datacenter, the replication strategy will default to SimpleStrategy. The number of nodes will determine the default replication factor:
number of nodes per datacenter graph_name replication factor (replication) graph_name_system replication factor (systemReplication)
1-3 number of nodes per datacenter number of nodes per datacenter
greater than 3 3 5
Important: Because the graph's schema is stored in graph_name_system, it is extremely important that the replication factor is set consistent with the table values above. If the graph's schema is lost, it renders the entire graph inoperable. Once set, the replication factor for these keyspaces cannot be altered.
The system replication settings can be verified using the cqlsh tool, running the CQL command DESCRIBE keyspace food_system command:
with a result:
CREATE KEYSPACE food_system WITH replication = {'class': 'NetworkTopologyStrategy', 'dc1: '3', 'dc2' : 2 }  AND durable_writes = true;
options (arg)
Options that can be set when creating a graph; see option for details on available options.
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 before attempting the operations.

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 an existing graph using this command. All data will be removed from the graph.


Drop an existing graph using this command. All data and schema will be lost. For better performance, truncate a graph before dropping it.


Check existence of a graph using this command.


Create a graph
Create a new graph without checking for the existence of a graph with the specified name:
The resulting list:
Create a new graph if it doesn't currently exist by modifying with ifNotExists().
The resulting list:
Creating a graph should include setting the replication factor for the graph and system replicaton factor for the graph_system. It can also include other options to set schema settings. For example, create a new graph, setting replication factors and options:
  replication("{'class' : 'NetworkTopologyStrategy', 'dc1' : 3, 'dc2' : 2 }").  
  systemReplication("{'class' : 'NetworkTopologyStrategy', 'dc1' : 3, 'dc2' : 2 }").
A wildcard * sets the write consistency for all transaction groups.
Restriction: The replication factor and system replication factor cannot be altered once set for the graph_name and graph_name_system keyspaces.
Truncate a graph
Truncate a graph.
The resulting list:
Truncate an existing graph if it exists.
The resulting list:
Drop a graph
Drop a graph.
The resulting list:
Drop an existing graph if it exists.
The resulting list:
Check graph existence
Discover if a particular graph exists. The return value is a boolean value.
The resulting list:
Setting system graph options
Options can be set when a graph is created with the System API. However, to check the schema settings, use the schema option to describe:
the results:
graph.schema_mode: Development
graph.allow_scan: False
graph.tx_groups.*.write_consistency: ALL
graph.default_property_key_cardinality: Multiple
gremlin> schema.config().option("graph.allow_scan").set("true")