Skip to Content
Cypher ManualDDL Clause

DDL Clause

DDL (Data Definition Language) is a set of operations specifically designed for schema management. NeuG supports operations for adding, deleting, and modifying schema nodes, edges, and properties. When creating property related schema, users can optionally specify default values for properties to prevent NULL fields during data ingestion. If a default value is not explicitly provided, the system will automatically assign the defined default value.

The following table lists the recommended syntax for defining default values for each supported data type, along with the system-assigned default value used when no explicit default is provided.

Data TypeDefault Value ExampleSystem Default Value
INT32prop INT32 DEFAULT 00
INT64prop INT64 DEFAULT 00
UINT32prop UINT32 DEFAULT 00
UINT64prop UINT64 DEFAULT 00
DOUBLEprop DOUBLE DEFAULT 0.00.0
FLOATprop FLOAT DEFAULT 0.00.0
STRINGprop STRING DEFAULT '''' (empty string)
DATEprop DATE DEFAULT DATE('1970-01-01')DATE('1970-01-01')
TIMESTAMPprop TIMESTAMP DEFAULT TIMESTAMP('1970-01-01')TIMESTAMP('1970-01-01')
INTERVALprop INTERVAL DEFAULT INTERVAL('0 year 0 month 0 day')INTERVAL('0 year 0 month 0 day')

Please refer to the following examples for more usages.

Create Node Type

Create a node with Label type “person”, specifying the property names, types, and primary key for the person.

CREATE NODE TABLE person ( name STRING, age INT32, PRIMARY KEY (name) );

By default, if a person type already exists in the database, an error will be reported. Use IF NOT EXISTS to avoid errors - it will only create if the type doesn’t exist in the database, otherwise it will do nothing.

CREATE NODE TABLE IF NOT EXISTS person ( name STRING, age INT32, PRIMARY KEY (name) );

Create Edge Type

Create an edge of type “knows” from person to person, specifying the property names and types for knows. Currently, edges do not support specifying primary keys.

CREATE REL TABLE IF NOT EXISTS knows ( FROM person TO person, weight DOUBLE );

Multiplicity

Optionally, you can add exactly one multiplicity token after the last column definition (and a comma), before the closing ) of the CREATE REL TABLE header. It describes cardinality along the forward direction (from source to target). Allowed values are ONE_TO_ONE, ONE_TO_MANY, MANY_TO_ONE, and MANY_TO_MANY. If you omit it, the edge type uses MANY_TO_MANY by default.

For example, on the same person / knows / weight shape as above:

CREATE REL TABLE IF NOT EXISTS knows ( FROM person TO person, weight DOUBLE, MANY_TO_MANY );

Table options (WITH)

You can append a WITH ( … ) clause after the closing ) of the table header. Inside the parentheses, pass one or more options as name = value, where values are literals. A common key is sort_key_for_nbr, whose value is typically a string literal naming an edge property used for ordering. The clause is optional.

Example, still with person, knows, and weight only—here weight is used as the sort column name:

CREATE REL TABLE IF NOT EXISTS knows ( FROM person TO person, weight DOUBLE ) WITH (sort_key_for_nbr = 'weight');

Where multiplicity and options apply

Multiplicity and WITH options are defined at edge type scope (the edge name and its shared column definitions), not at the level of an individual source–edge–target triplet. When a rel table declares multiple FROM … TO … entries for the same edge type, a single multiplicity value and a single option set apply uniformly to every such pair; per-pair multiplicity or option bindings are not supported.

Drop Node Type

Delete a specified Node type. Use IF EXISTS to avoid errors when the type doesn’t exist.

DROP TABLE IF EXISTS person;

Drop Edge Type

Delete a specified Edge type. Use IF EXISTS to avoid errors when the type doesn’t exist.

DROP TABLE IF EXISTS knows;

Rename Node or Edge Type

Rename a node or edge type by RENAME TO.

ALTER TABLE person RENAME TO person2; ALTER TABLE knows RENAME TO knows2;

Add Property

Add properties to a node or edge type.

ALTER TABLE person ADD IF NOT EXISTS gender INT32; ALTER TABLE knows ADD IF NOT EXISTS info STRING;

Drop Property

Remove properties from a node or edge type.

ALTER TABLE person DROP IF EXISTS gender; ALTER TABLE knows DROP IF EXISTS info;

Rename Property

Rename properties of a node or edge type.

ALTER TABLE person RENAME age TO age2; ALTER TABLE knows RENAME weight TO weight2;