DESCRIBE TABLE文

構文

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

セマンティクス

表の説明には、次の情報が含まれます。

  • 表の名前。
  • 表の存続期間の値。
  • 表の所有者。
  • 表がシステム表かどうか。
  • 親表の名前。
  • 子表の名前。
  • 表に存在する索引のリスト。
  • 表の説明。

フィールドの説明には、次の情報が含まれます。

  • フィールドのID。
  • フィールドの名前。
  • INTEGER、STRING、Map(INTEGER)などのフィールドのデータ型。
  • フィールドがNULL値可能かどうか。フィールドがNULL値可能である場合は「Y」が表示され、そうでない場合は「N」が表示されます。
  • フィールドのデフォルト値。
  • フィールドがシャード・キーかどうか。フィールドがシャード・キーの場合は「Y」が表示され、そうでない場合は「N」が表示されます。
  • フィールドが主キーかどうか。フィールドが主キーの場合は「Y」が表示され、そうでない場合は「N」が表示されます。
  • フィールドがアイデンティティ・フィールドかどうか。フィールドがアイデンティティ・フィールドの場合は「Y」が表示され、そうでない場合は「N」が表示されます。

出力をJSON形式にする場合、AS JSONを指定できます。

例5-5 Describe Table

出力をJSON形式にする場合、AS JSONを指定できます。

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 |          |            |          |
 +----+-------------+---------------------+----------+-----------+----------+------------+----------+

例5-6 Describe Table

次の文は、users表およびそのフィールドに関する情報をJSON形式で提供します。

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
  } ]
}

例5-7 Describe Table

次の文は、users表の特定のフィールドに関する情報を提供します。

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