Skip to content

NULL

You can set the properties for vertices or edges to NULL. Also, you can set the NOT NULL constraint to make sure that the property values are NOT NULL. If not specified, the property is set to NULL by default.

Logical operations with NULL

Here is the truth table for AND, OR, XOR, and NOT.

a b a AND b a OR b a XOR b NOT a
false false false false false true
false null false null null true
false true false true true true
true false false true true false
true null null true null false
true true true true false false
null false false null null null
null null null null null null
null true null true null null

OpenCypher compatibility

The comparisons and operations about NULL are different from openCypher. There may be changes later.

Comparisons with NULL

The comparison operations with NULL are incompatible with openCypher.

Operations and RETURN with NULL

The NULL operations and RETURN with NULL are incompatible with openCypher.

Examples

Use NOT NULL

Create a tag named player. Specify the property name as NOT NULL.

nebula> CREATE TAG IF NOT EXISTS player(name string NOT NULL, age int);

Use SHOW to create tag statements. The property name is NOT NULL. The property age is NULL by default.

nebula> SHOW CREATE TAG player;
+-----------+-----------------------------------+
| Tag       | Create Tag                        |
+-----------+-----------------------------------+
| "student" | "CREATE TAG `player` (            |
|           |  `name` string NOT NULL,          |
|           |  `age` int64 NULL                 |
|           | ) ttl_duration = 0, ttl_col = """ |
+-----------+-----------------------------------+

Insert the vertex Kobe. The property age can be NULL.

nebula> INSERT VERTEX player(name, age) VALUES "Kobe":("Kobe",null);

Use NOT NULL and set the default

Create a tag named player. Specify the property age as NOT NULL. The default value is 18.

nebula> CREATE TAG IF NOT EXISTS player(name string, age int NOT NULL DEFAULT 18);

Insert the vertex Kobe. Specify the property name only.

nebula> INSERT VERTEX player(name) VALUES "Kobe":("Kobe");

Query the vertex Kobe. The property age is 18 by default.

nebula> FETCH PROP ON player "Kobe" YIELD properties(vertex);
+--------------------------+
| properties(VERTEX)       |
+--------------------------+
| {age: 18, name: "Kobe"}  |
+--------------------------+

Last update: October 24, 2023