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.
Synopsis
system.graph('graph_name'). 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 }"). [options(arg)]. [ifNotExists().] create() | [ifExists().]truncate() | [ifExists().]drop() | exists()
- replication, systemReplication
-
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 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 thecqlsh
tool, running the CQL commandDESCRIBE keyspace food_system
command:DESCRIBE KEYSPACE food_system;
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
-
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('fridge_item').create()The resulting list:
==>fridge_item
ifNotExists()
.
system.graph('fridge_item').ifNotExists().create()The resulting list:
==>fridge_item
system.graph('food2'). replication("{'class' : 'NetworkTopologyStrategy', 'dc1' : 3, 'dc2' : 2 }"). systemReplication("{'class' : 'NetworkTopologyStrategy', 'dc1' : 3, 'dc2' : 2 }"). option("graph.schema_mode").set("Development"). option("graph.allow_scan").set("false"). option("graph.default_property_key_cardinality").set("multiple"). option("graph.tx_groups.*.write_consistency").set("ALL"). ifNotExists().create()A wildcard
*
sets the write consistency for all transaction groups. graph_name
and
graph_name_system
keyspaces.system.graph('fridge_item').truncate()The resulting list:
==>null
system.graph('pedometer').ifExists().truncate()The resulting list:
==>null
system.graph('fridge_item').drop()The resulting list:
==>OK
system.graph('fridge_sensors').ifExists().drop()The resulting list:
==>null
system.graph('fridge_item').exists()The resulting list:
==>true
schema.config().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")