Skip to main content

"describeTables"

JSON DB "describeTables" action returns a complete set of metadata about one or more specified tables

The "describeTables" action returns a complete set of metadata about one or more specified tables.

Request examples

Minimal request

{
  "api": "db",
  "authToken": "replaceWithValidAuthtoken",
  "action": "describeTables",
  "params": {
    "tableNames": [
      "test1"
    ]
  }
}
{
  "api": "db",
  "apiVersion": "1.0",
  "requestId": "2",
  "authToken": "replaceWithValidAuthtoken",
  "action": "describeTables",
  "params": {
    "databaseName": "ctreeSQL",
    "ownerName": "admin",
    "tableNames": [
      "athlete"
    ]
  },
  "responseOptions": {
    "binaryFormat": "hex",
    "dataFormat": "objects",
    "numberFormat": "string"
  },
  "debug": "max"
}
{
  "authToken": "replaceWithValidAuthtoken",
  "result": {
    "dataFormat": "objects",
    "data": [
      {
        "changeIdField": "changeId",
        "createRecByteIndex": false,
        "databaseName": "ctreeSQL",
        "fieldDelimiterValue": 0,
        "fields": [
          {
            "autoValue": "incrementOnInsert",
            "defaultValue": null,
            "length": null,
            "name": "id",
            "nullable": false,
            "primaryKey": 1,
            "scale": null,
            "type": "bigint"
          },
          {
            "autoValue": "changeId",
            "defaultValue": null,
            "length": null,
            "name": "changeId",
            "nullable": true,
            "primaryKey": 0,
            "scale": null,
            "type": "bigint"
          },
          {
            "autoValue": "none",
            "defaultValue": null,
            "length": 50,
            "name": "name",
            "nullable": true,
            "primaryKey": 0,
            "scale": null,
            "type": "varchar"
          }
        ],
        "folder": ".\\ctreeSQL.dbs",
        "growthExtent": 0,
        "indexFileExtension": ".idx",
        "indexes": [
          {
            "collectStats": false,
            "compression": "off",
            "conditionalExpression": null,
            "databaseName": "ctreeSQL",
            "deferIndexing": false,
            "fields": [
              {
                "caseInsensitive": false,
                "name": "id",
                "reverseCompare": false,
                "sortDescending": false
              }
            ],
            "filename": "admin_test1.idx",
            "immutableKeys": false,
            "indexName": "id_pk",
            "indexNumber": 0,
            "ownerName": "admin",
            "tableName": "test1",
            "unique": true
          }
        ],
        "ownerName": "admin",
        "padValue": 0,
        "path": ".\\ctreeSQL.dbs\\admin_test1.dat",
        "primaryKeyFields": [
          "id"
        ],
        "smallFile": false,
        "tableFileExtension": ".dat",
        "tableName": "test1",
        "totalRecordCount": 0,
        "transactionModel": "logTransactions",
        "uid": 1181
      }
    ]
  },
  "debugInfo": {
    "request": {
      "authToken": "replaceWithValidAuthtoken",
      "api": "db",
      "action": "describeTables",
      "params": {
        "tableNames": [
          "test1"
        ]
      },
      "debug": "max"
    },
    "serverSuppliedValues": {
      "databaseName": "ctreeSQL",
      "ownerName": "admin"
    },
    "errorData": {
      "errorData": null
    },
    "warnings": []
  },
  "errorCode": 0,
  "errorMessage": ""
}
{
  "authToken": "replaceWithValidAuthtoken",
  "result": {
    "dataFormat": "objects",
    "data": [
      {
        "changeIdField": "changeId",
        "createRecByteIndex": false,
        "databaseName": "ctreeSQL",
        "fieldDelimiterValue": 0,
        "fields": [
          {
            "autoValue": "incrementOnInsert",
            "defaultValue": null,
            "length": null,
            "name": "id",
            "nullable": false,
            "primaryKey": 1,
            "scale": null,
            "type": "bigint"
          },
          {
            "autoValue": "changeId",
            "defaultValue": null,
            "length": null,
            "name": "changeId",
            "nullable": true,
            "primaryKey": 0,
            "scale": null,
            "type": "bigint"
          },
          {
            "autoValue": "none",
            "defaultValue": null,
            "length": 30,
            "name": "name",
            "nullable": true,
            "primaryKey": 0,
            "scale": null,
            "type": "varchar"
          },
          {
            "autoValue": "none",
            "defaultValue": null,
            "length": null,
            "name": "ranking",
            "nullable": false,
            "primaryKey": 0,
            "scale": null,
            "type": "smallint"
          },
          {
            "autoValue": "none",
            "defaultValue": null,
            "length": null,
            "name": "birthDate",
            "nullable": true,
            "primaryKey": 0,
            "scale": null,
            "type": "date"
          },
          {
            "autoValue": "none",
            "defaultValue": null,
            "length": 32,
            "name": "playerNumber",
            "nullable": true,
            "primaryKey": 0,
            "scale": 6,
            "type": "number"
          },
          {
            "autoValue": "none",
            "defaultValue": null,
            "length": null,
            "name": "livedPast2000",
            "nullable": true,
            "primaryKey": 0,
            "scale": null,
            "type": "bit"
          },
          {
            "autoValue": "none",
            "defaultValue": null,
            "length": 32,
            "name": "earnings",
            "nullable": true,
            "primaryKey": 0,
            "scale": 4,
            "type": "money"
          },
          {
            "autoValue": "none",
            "defaultValue": null,
            "length": 500,
            "name": "favoriteSaying",
            "nullable": true,
            "primaryKey": 0,
            "scale": null,
            "type": "varchar"
          }
        ],
        "folder": ".\\ctreeSQL.dbs",
        "growthExtent": 0,
        "indexFileExtension": ".idx",
        "indexes": [
          {
            "collectStats": false,
            "compression": "off",
            "conditionalExpression": null,
            "databaseName": "ctreeSQL",
            "deferIndexing": false,
            "fields": [
              {
                "caseInsensitive": false,
                "name": "id",
                "reverseCompare": false,
                "sortDescending": false
              }
            ],
            "filename": "admin_athlete.idx",
            "immutableKeys": false,
            "indexName": "id_pk",
            "indexNumber": 0,
            "ownerName": "admin",
            "tableName": "athlete",
            "unique": true
          }
        ],
        "ownerName": "admin",
        "padValue": 0,
        "path": ".\\ctreeSQL.dbs\\admin_athlete.dat",
        "primaryKeyFields": [
          "id"
        ],
        "smallFile": false,
        "tableFileExtension": ".dat",
        "tableName": "athlete",
        "totalRecordCount": 0,
        "transactionModel": "logTransactions",
        "uid": 1185
      }
    ]
  },
  "requestId": "2",
  "debugInfo": {
    "request": {
      "authToken": "replaceWithValidAuthtoken",
      "api": "db",
      "action": "describeTables",
      "params": {
        "databaseName": "ctreeSQL",
        "ownerName": "admin",
        "tableNames": [
          "athlete"
        ]
      },
      "apiVersion": "1.0",
      "requestId": "2",
      "responseOptions": {
        "binaryFormat": "hex",
        "dataFormat": "objects",
        "numberFormat": "string"
      },
      "debug": "max"
    },
    "serverSuppliedValues": {
      "databaseName": "ctreeSQL",
      "ownerName": "admin"
    },
    "errorData": {
      "errorData": null
    },
    "warnings": []
  },
  "errorCode": 0,
  "errorMessage": ""
}

Use the describeTables JSON API action to return a complete set of metadata about one or more specified tables

API actionsJSON DB APIjsonActiontable actionsdescribe tabledescribeTables

The "params" property is an object that contains an action's parameters. Each action defines its own required and optional properties.

Properties summary

Table 1. "params" properties summary

Property

Description

Default

Type

Limits (inclusive)

databaseName

specifies the name of a database

Defaults to the "defaultDatabaseName" value that is set during "createSession". If no default is set during "createSession", then "faircom" is used.

string

1 to 64 bytes

ownerName

specifies the unique name of a schema in a database

""

string

1 to 64 bytes

primaryKeys

specifies key values used by "getRecordsByIds" to find and return one or more records. It is mutually exclusive with "ids".

"null"

Required when "ids" is omitted.

array of arrays

tableNames

lists table names to return in the response message

Required - No default value

array

1 to 64 bytes



The "databaseName" property is an optional string that specifies the database that contains the tables. It defaults to the database name supplied at login.

Note

In the API Explorer, "defaultDatabaseName" is set to "ctreeSQL" in the "createSession" action that happens at login.

  • A zero-length "databaseName" is invalid.

  • Its limits are from 0 to 64 bytes.

  • If the "databaseName" property is omitted or set to null, the server will use the default database name specified at login.

  • If no default database is specified during "createSession", "defaultDatabaseName" will be set to the "defaultDatabaseName" value that is specified in the services.json file.

The "ownerName" property is an optional string from 1 to 64 bytes that specifies the account that owns an object.

The "primaryKeys" property is an array of arrays that contain key values used by the "getRecordsByIds" action to find and return one or more records. The default value is "null" but it is required if the "ids" property is omitted.

  • "primaryKeys" is best used if tables were created with primary keys composed of multiple fields. If primary keys are composed of a single field, it is best to use "ids".

    Note

    Tables created using JSON DB API actions cannot create primary keys composed of multiple fields.

  • A table must have a primary key defined in order to use "primaryKeys"

  • The "primaryKeys" property is mutually exclusive with the "ids" property meaning it is required when "ids" is omitted or an error is returned if both have values.

  • The  "primaryKeys" property is an array of arrays

    • The outer array contains one or more primary key definitions which allow the server to retrieve multiple records at a time.

    • Each inner array is a primary key definition that specifies the values the server needs to retrieve one matching record.

    • A primary key definition consists of one or more objects where each object is a field-value pair that uses the following structure ({ "fieldName": "someField","value": "someValue" }).

Example

If your table uses the "first_name" and "last_name" fields as the primary key, the following "primaryKeys" property will retrieve two records.

Note

If your table does not have a primary key, its records cannot be retrieved, updated or deleted using the "getRecordsByIds", "updateRecords" and "deleteRecords" actions. Other getRecords actions can query its records.

   "primaryKeys": 
    [ 
      [
        { "fieldName": "first_name", "value": "Sam" },
        { "fieldName": "last_name",  "value": "I-am" }
      ],
      [
        { "fieldName": "first_name", "value": "The Cat" },
        { "fieldName": "last_name",  "value": "in the Hat" }
      ]
    ]

The "tableNames" property is a required array of strings. Each string is from 1 to 64 bytes.

  • Contains at least one string.

  • Each string is the name of a table.

  • A zero-length "tableName" is invalid.

  • A client should force the uniqueness of items in the array because the server ignores duplicate items.

Properties summary

Table 2. "result" properties summary

Property

Description

Type

Limits (inclusive)

data

specifies an array or object that the server returns, such as records returned by a query. It is an empty array when no results are available.

array

Its contents are determined by the action

dataFormat

specifies the format of the data in the "data" property

string

"autoDetect"
"arrays"
"objects"


The "dataFormat" property is an optional, case-insensitive string enum that defines the format of the response in the "data" property. The default format is an array of arrays. The alternative is an array of objects. The default for "dataFormat" can be changed during a "createSession" action by assigning a different value to the "dataFormat" property in "defaultResponseOptions".

There are three different (but similar) versions of the "dataFormat" property:

Two of those versions occur in a request and another occurs in a response. They all indicate how data is formatted.

  • "dataFormat" in the request inside "responseOptions" determines how the "data" property in the response is formatted.

    Possible values include:

    • "arrays"

      This is the default and causes the server to return results as an array of arrays, which is the most efficient.

    • "objects"

      This returns results as an array of objects. This is less efficient but is simpler to generate, read, and troubleshoot.

  • "dataFormat" in the request in the "params" object notifies the server how the "sourceData" property is formatted in the request. This version is rarely used because of the default "autoDetect" behavior.

    Possible values include:

    • "arrays"

      This causes the server to return results as an array of arrays, which is the most efficient.

    • "objects"

      This returns results as an array of objects. This is less efficient but is simpler to generate, read, and troubleshoot.

    • "autoDetect"

      This is the default and causes the server to automatically detect the format of the data in the "sourceData" property.

  • "dataFormat" in the response shows the client how the server formatted the "data" property.

    Possible values include:

    • "arrays"

      This is the default and causes the server to return results as an array of arrays, which is the most efficient.

    • "objects"

      This returns results as an array of objects. This is less efficient but is simpler to generate, read, and troubleshoot.