Skip to content
Developer Edition runs on one host and does not require a product license file. Need multi-host deployment or performance testing at scale? Explore Enterprise Edition

Table types

A table type describes tabular data composed of named fields and rows. Each field has a value type. For example, TABLE {id INT64, name STRING} describes a table with an id field of type INT64 and a name field of type STRING.

Table types cannot be used as node or edge property types.

View a table type

Use the typeof() function to view the type of a table variable:

'''
TABLE t TYPED TABLE {id INT64, name STRING} =
    {id: 10001, name: 'Alice'},
    {id: 10002, name: 'Bob'}
RETURN typeof(t) AS t_type
'''

Return:

+-------------------------------+
| t_type                        |
+-------------------------------+
| TABLE {id INT64, name STRING} |
+-------------------------------+

The returned type contains the name and value type of each field.

Table types and table variables

A table type describes the structure of tabular data, whereas a table variable stores or refers to the data:

TABLE t TYPED TABLE {id INT64, name STRING}

In this declaration:

  • t is the table variable.
  • TABLE {id INT64, name STRING} is its table type.
  • The first TABLE keyword introduces the table variable declaration.

For the complete declaration syntax, see Table variables.

Use a table type as a procedure parameter

A user-defined procedure (UDP) can accept a table through a parameter declared with TABLE:

parameter_name TABLE

In this syntax, TABLE accepts a table variable passed by the caller. For more information, see CREATE PROCEDURE.

Usage

Table types are mainly used for:

  • Table variables that store intermediate data or results.
  • UDP parameters that receive tables.
  • Data exchanged through IMPORT and EXPORT.

Table variables in NebulaGraph Database Developer Edition

In NebulaGraph Database Developer Edition, the field names and types of a table variable can also be inferred from an initializer or query result. Local table variables can be iterated with FOR.

Limitations

  • Table types cannot be used as node or edge property types.
  • The values written to a table must be compatible with its field types.

See also