DESCRIBE TABLE Statement

Syntax

describe_table_statement ::=
    (DESCRIBE | DESC) [AS JSON] TABLE table_name 
    [ "(" field_name ["," field_name] ")"]

Semantics

The description for tables contains the following information:

  • Name of the table.
  • Time-To-Live value of the table.
  • Owner of the table.
  • Whether the table is a system table.
  • Name of parent tables.
  • Name of children tables.
  • List of indexes present on the table.
  • Desciption of the table.

The description for fields contains the following information:

  • Id of the field.
  • Name of the field.
  • Datatype of fields, for example, INTEGER, STRING, Map(INTEGER), etc.
  • Whether the field is nullable. If the field is nullable then 'Y' is displayed, otherwise 'N' is displayed.
  • Default value of the field.
  • Whether the field is a shard key. If the field is a shard key then 'Y' is displayed, otherwise 'N' is displayed.
  • Whether the field is a primary key. If the field is a primary key then 'Y' is displayed, otherwise 'N' is displayed.
  • Whether the field is an identity field. If the field is an identity field then 'Y' is displayed, otherwise 'N' is displayed.

AS JSON can be specified if you want the output to be in JSON format.

Example 5-5 Describe Table

AS JSON can be specified if you want the output to be in JSON format.

DESCRIBE TABLE users;
 
 === Information ===
 +-------+-----+-------+----------+----------+--------+----------+---------+-------------+
 | name  | ttl | owner | sysTable | r2compat | parent | children | indexes | description |
 +-------+-----+-------+----------+----------+--------+----------+---------+-------------+
 | users |     |       | N        | N        |        |          |         |             |
 +-------+-----+-------+----------+----------+--------+----------+---------+-------------+
 
 === Fields ===
 +----+-------------+---------------------+----------+-----------+----------+------------+----------+
 | id |    name     |        type         | nullable |  default  | shardKey | primaryKey | identity |
 +----+-------------+---------------------+----------+-----------+----------+------------+----------+
 |  1 | id          | Integer             | N        | NullValue | Y        | Y          |          |
 +----+-------------+---------------------+----------+-----------+----------+------------+----------+
 |  2 | firstName   | String              | Y        | NullValue |          |            |          |
 +----+-------------+---------------------+----------+-----------+----------+------------+----------+
 |  3 | lastName    | String              | Y        | NullValue |          |            |          |
 +----+-------------+---------------------+----------+-----------+----------+------------+----------+
 |  4 | otherNames  | Array(              | Y        | NullValue |          |            |          |
 |    |             |   RECORD(           |          |           |          |            |          |
 |    |             |     first : String, |          |           |          |            |          |
 |    |             |     last : String   |          |           |          |            |          |
 |    |             |   ))                |          |           |          |            |          |
 +----+-------------+---------------------+----------+-----------+----------+------------+----------+
 |  5 | age         | Integer             | Y        | NullValue |          |            |          |
 +----+-------------+---------------------+----------+-----------+----------+------------+----------+
 |  6 | income      | Integer             | Y        | NullValue |          |            |          |
 +----+-------------+---------------------+----------+-----------+----------+------------+----------+
 |  7 | address     | Json                | Y        | NullValue |          |            |          |
 +----+-------------+---------------------+----------+-----------+----------+------------+----------+
 |  8 | connections | Array(Integer)      | Y        | NullValue |          |            |          |
 +----+-------------+---------------------+----------+-----------+----------+------------+----------+
 |  9 | expenses    | Map(Integer)        | Y        | NullValue |          |            |          |
 +----+-------------+---------------------+----------+-----------+----------+------------+----------+

Example 5-6 Describe Table

The following statement provides information about the users table and its fields in JSON format.

DESC AS JSON TABLE users;
 
{
  "json_version" : 1,
  "type" : "table",
  "name" : "users",
  "shardKey" : [ "id" ],
  "primaryKey" : [ "id" ],
  "fields" : [ {
    "name" : "id",
    "type" : "INTEGER",
    "nullable" : false,
    "default" : null
  }, {
    "name" : "firstName",
    "type" : "STRING",
    "nullable" : true,
    "default" : null
  }, {
    "name" : "lastName",
    "type" : "STRING",
    "nullable" : true,
    "default" : null
  }, {
    "name" : "otherNames",
    "type" : "ARRAY",
    "collection" : {
      "name" : "RECORD_gen",
      "type" : "RECORD",
      "fields" : [ {
        "name" : "first",
        "type" : "STRING",
        "nullable" : true,
        "default" : null
      }, {
        "name" : "last",
        "type" : "STRING",
        "nullable" : true,
        "default" : null
      } ]
    },
    "nullable" : true,
    "default" : null
  }, {
    "name" : "age",
    "type" : "INTEGER",
    "nullable" : true,
    "default" : null
  }, {
    "name" : "income",
    "type" : "INTEGER",
    "nullable" : true,
    "default" : null
  }, {
    "name" : "address",
    "type" : "JSON",
    "nullable" : true,
    "default" : null
  }, {
    "name" : "connections",
    "type" : "ARRAY",
    "collection" : {
      "type" : "INTEGER"
    },
    "nullable" : true,
    "default" : null
  }, {
    "name" : "expenses",
    "type" : "MAP",
    "collection" : {
      "type" : "INTEGER"
    },
    "nullable" : true,
    "default" : null
  } ]
}

Example 5-7 Describe Table

The following statement provides information about a specific field in the users table.

DESCRIBE TABLE users (income);
 
 +----+--------+---------+----------+-----------+----------+------------+----------+
 | id |  name  |  type   | nullable |  default  | shardKey | primaryKey | identity |
 +----+--------+---------+----------+-----------+----------+------------+----------+
 |  1 | income | Integer | Y        | NullValue |          |            |          |
 +----+--------+---------+----------+-----------+----------+------------+----------+