DESCRIBE TABLE Statement

Syntax

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

For definition of the syntax component referenced in this statement, see:

Semantics

The description for tables contains the following information:

The description for fields contains the following information:

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

Example 1 - Describe Table

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

DESCRIBE TABLE users

Output:

=== 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 2 - Describe Table

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

DESC AS JSON TABLE users

Output:

{
  "json_version" : 2,
  "type" : "table",
  "name" : "users",
  "id" : "57",
  "fields" : [{
    "name" : "id",
    "type" : "INTEGER",
    "nullable" : false
  }, {
    "name" : "firstName",
    "type" : "STRING",
    "nullable" : true
  }, {
    "name" : "lastName",
    "type" : "STRING",
    "nullable" : true
  }, {
    "name" : "otherNames",
    "type" : "ARRAY",
    "nullable" : true,
    "collection" : {
      "type" : "RECORD",
      "fields" : [{
        "name" : "first",
        "type" : "STRING",
        "nullable" : true
      }, {
        "name" : "last",
        "type" : "STRING",
        "nullable" : true
      }]
    }
  }, {
    "name" : "age",
    "type" : "INTEGER",
    "nullable" : true
  }, {
    "name" : "income",
    "type" : "INTEGER",
    "nullable" : true
  }, {
    "name" : "address",
    "type" : "JSON",
    "nullable" : true
  }, {
    "name" : "connections",
    "type" : "ARRAY",
    "nullable" : true,
    "collection" : {
      "type" : "INTEGER"
    }
  }, {
    "name" : "hobbies",
    "type" : "ARRAY",
    "nullable" : true,
    "collection" : {
      "type" : "STRING"
    }
  }],
  "primaryKey" : ["id"],
  "shardKey" : ["id"],
  "indexes" : [{
    "name" : "idx_modtime",
    "type" : "secondary",
    "fields" : [{
      "function" : "modification_time",
      "type" : "Timestamp(3)"
    }],
    "withNoNulls" : false,
    "withUniqueKeysPerRow" : false
  }]
}

Example 3 - Describe Table

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

DESCRIBE TABLE users (income)

Output:

+----+--------+---------+----------+-----------+----------+------------+----------+
| id |  name  |  type   | nullable |  default  | shardKey | primaryKey | identity |
+----+--------+---------+----------+-----------+----------+------------+----------+
|  1 | income | Integer | Y        | NullValue |          |            |          |
+----+--------+---------+----------+-----------+----------+------------+----------+