Skip to main content

"listTables" (JSON Action)

JSON DB "listTables" action lists tables in the specified database that the logged-in user is allowed to see

All available information about each table is listed.

Request examples

Minimal

{
  "api": "db",
  "action": "listTables",
  "params": {},
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
{
  "api": "db",
  "apiVersion": "1.0",
  "requestId": "2",
  "action": "listTables",
  "params": {
    "databaseName": "ctreeSQL",
    "partialTableName": "a"
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
{
  "api": "db",
  "apiVersion": "1.0",
  "requestId": "3",
  "action": "listTables",
  "params": {
    "databaseName": "ctreeSQL",
    "tableNames": [
      "athlete",
      "test1"
    ]
  },
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
{
  "api": "db",
  "apiVersion": "1.0",
  "requestId": "4",
  "action": "listTables",
  "params": {
    "databaseName": "ctreeSQL",
    "ownerName": "admin",
    "skipRecords": 1,
    "maxRecords": 3,
    "includeSystemTables": false
  },
  "debug": "max",
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

Minimal

{
  "result": {
    "dataFormat": "objects",
    "data": [
      {
        "databaseName": "ctreeSQL",
        "ownerName": "admin",
        "path": "./ctreeSQL.dbs",
        "tableName": "all_types",
        "totalRecordCount": -1,
        "uid": 1189
      },
      {
        "databaseName": "ctreeSQL",
        "ownerName": "admin",
        "path": ".\\ctreeSQL.dbs",
        "tableName": "athlete",
        "totalRecordCount": -1,
        "uid": 1185
      },
      {
        "databaseName": "ctreeSQL",
        "ownerName": "admin",
        "path": ".\\ctreeSQL.dbs",
        "tableName": "test1",
        "totalRecordCount": -1,
        "uid": 1181
      }
    ]
  },
  "errorCode": 0,
  "errorMessage": "",
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
{
  "result": {
    "dataFormat": "objects",
    "data": [
      {
        "databaseName": "ctreeSQL",
        "ownerName": "admin",
        "path": "./ctreeSQL.dbs",
        "tableName": "all_types",
        "totalRecordCount": -1,
        "uid": 1189
      },
      {
        "databaseName": "ctreeSQL",
        "ownerName": "admin",
        "path": ".\\ctreeSQL.dbs",
        "tableName": "athlete",
        "totalRecordCount": -1,
        "uid": 1185
      }
    ]
  },
  "requestId": "2",
  "errorCode": 0,
  "errorMessage": "",
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
{
  "result": {
    "dataFormat": "objects",
    "data": [
      {
        "databaseName": "ctreeSQL",
        "ownerName": "admin",
        "path": ".\\ctreeSQL.dbs",
        "tableName": "athlete",
        "totalRecordCount": -1,
        "uid": 1185
      },
      {
        "databaseName": "ctreeSQL",
        "ownerName": "admin",
        "path": ".\\ctreeSQL.dbs",
        "tableName": "test1",
        "totalRecordCount": -1,
        "uid": 1181
      }
    ]
  },
  "requestId": "3",
  "errorCode": 0,
  "errorMessage": "",
  "authToken": "replaceWithAuthTokenFromCreateSession"
}
{
  "result": {
    "dataFormat": "objects",
    "data": [
      {
        "databaseName": "ctreeSQL",
        "ownerName": "admin",
        "path": ".\\ctreeSQL.dbs",
        "tableName": "athlete",
        "totalRecordCount": -1,
        "uid": 1185
      },
      {
        "databaseName": "ctreeSQL",
        "ownerName": "admin",
        "path": ".\\ctreeSQL.dbs",
        "tableName": "test1",
        "totalRecordCount": -1,
        "uid": 1181
      }
    ]
  },
  "requestId": "4",
  "debugInfo": {
    "request": {
      "api": "db",
      "action": "listTables",
      "params": {
        "databaseName": "ctreeSQL",
        "ownerName": "admin",
        "skipRecords": 1,
        "maxRecords": 3,
        "includeSystemTables": false
      },
      "apiVersion": "1.0",
      "requestId": "4",
      "debug": "max",
      "authToken": "replaceWithAuthTokenFromCreateSession"
    },
    "serverSuppliedValues": {
      "databaseName": "ctreeSQL",
      "ownerName": "admin"
    },
    "errorData": {
      "errorData": null
    },
    "warnings": []
  },
  "errorCode": 0,
  "errorMessage": "",
  "authToken": "replaceWithAuthTokenFromCreateSession"
}

Use the listTables JSON API action to list tables in the specified database that the logged-in user is allowed to see

API actionsJSON DB APIJSON Actiontable actionslist tablelistTables

The "params" property is an object that contains an action's request parameters as defined by a set of properties. Each action defines its own required and optional properties. See System limits for a comprehensive overview of property requirements and limitations.

Table 1. listTables "params" properties summary

Property

Description

Default

Type

Limits (inclusive)

databaseName

(optional) 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

includeSystemTables

(optional) includes the system tables in the list of tables when true.

false

Boolean

true
false

maxRecords

(optional) specifies the maximum number of records to return from an action. -1 returns all records.

20

integer

-1 to 65535

ownerName

(optional) specifies the unique name of a schema in a database.

""

string

1 to 64 bytes

partialTableName

(optional) filters the returned tables by returning tables that have this string value as the first part of the table name.

""

string

0 to 64 bytes

skipRecords

(optional) specifies the number of records to skip over in the results before returning records.

0

integer

0 to 9223372036854775807

tableNames

(optional) lists table names to return in the response message.

""

array

1 to 64 bytes

transactionId

(conditional) specifies a transaction ID if you are running listTables within a transaction that is creating a table. If you include the transaction ID the new table will be included in the list even though the transaction is not committed.

""

string

0 to 255 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 length limit is 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", "databaseName" will be set to the "defaultDatabaseName" value that is specified in the services.json file.

"params": {
  "databaseName": "mainDatabase"
  }

When this property value is true, the server response includes system tables in the list of tables.

The default value is false.

Example

"params": {
  "includeSystemTables": true
}

The "maxRecords" is an optional integer from -1 to 65535 that sets the maximum number of records to return from an action. It is used in query actions to paginate the query results when returning records directly. The default for most actions is to return 20 records.

Important

-1 returns all records and should be used very carefully because a large query can return so many records that it eventually times out and wastes server and client resources.

  • When present, "maxRecords" works in conjunction with the "skipRecords" (and, when applicable, "reverseOrder") properties to paginate results.

  • "maxRecords" returns an error when "returnCursor" is true.

    Note

    This does not apply to the actions where "returnCursor" is not present.

  • When returning a cursor, retrieve records using the "getRecordsFromCursor" action.

  • A value of 0 for "maxRecords" is not useful because it causes the action to return no records.

  • "maxRecords" is ignored by the "getRecordsByIds" action.

The "ownerName" property is an optional string from 1 to 64 bytes that identifies the user who owns an object (see Object owner). If it is omitted or set to "" or null, the server uses the default owner name supplied during the "createSession" action or uses the account's "username" as the owner name.

"params": {
  "ownerName": "SuperUser"
}

The "partialTableName" property is an optional string from 0 to 64 bytes that filters the returned databases by applying partial matches to database names. It defaults to an empty string.

  • The "listTables" action uses "partialTableName" to return all tables whose table names start with these same characters.

  • A zero-length string matches all table names.

The "skipRecords" property is an optional integer from 0 to 9223372036854775807. It is used in query actions to paginate the query results when returning records directly. It defaults to 0.

  • It specifies the number of records to skip over in the results before returning records.

  • It works with "maxRecords" and "reverseOrder".

  • It is ignored when "returnCursor" is true.

    Note

    This does not apply to the actions where "returnCursor" is not present.

The "tableNames" property is a required array of strings. Each string is a table name.

Note

See table name in System limits for table naming requirements and limitations.

  • Contains at least one string.

  • A zero-length "tableName" is invalid.

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

  • Including table names that do not exist will not result in an error. However, the "warnings" array in the reply will contain an object for each missing table.

The "transactionId" is an optional string that the server generates and returns during a "createTransaction" action. The generated ID represents a transaction. In requests, it defaults to an empty string.

  • When a client wants an action to be controlled by a transaction, the "transactionId" must be included in the action request.

  • A "transactionId" is valid and can be applied to multiple actions until it is either committed using "commitTransaction" or rolled back using "rollbackTransaction".

  • A zero-length string means the "transactionId" is invalid.

  • Do not assume that "transactionId" is a number embedded in a string.

Table 2. listTables "result" properties summary

Property

Description

Type

Limits (inclusive)

data

is an array of objects or arrays. Each item in the array describes a record. The array is empty if no results are available.

array

The action determines its contents.

dataFormat

identifies the format of the data in the "data" property.

string

"autoDetect"
"arrays"
"objects"


The "data" property is an array of objects or arrays that contain information about the database. The "dataFormat" property specifies whether the content is arrays or objects. The initiating action defines the data contents. In results messages, when no results are available, it is empty. For path formats, see "path".

Examples

arrays
"data":
[
  ["test1", ".\\test1.dbs\\SQL_SYS", 1003]
]
objects
"data":
[
  {
    "databaseName": "test7",
    "path": ".\\test7.dbs\\SQL_SYS",
    "uid": 1015
  }
]

The "dataFormat" property is a case-insensitive string enum that defines the format of 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 in "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 the server automatically detects 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.

Example response

{
  "result": {
    "dataFormat": "objects"
  }
}