"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
The "params"
property is an object that contains an action's parameters. Each action defines its own required and optional properties.
Properties summary
"params"
properties summaryProperty | Description | Default | Type | Limits (inclusive) |
---|---|---|---|---|
specifies the name of a database | Defaults to the | string | 1 to 64 bytes | |
specifies the unique name of a schema in a database |
| string | 1 to 64 bytes | |
specifies key values used by |
Required when | array of arrays | ||
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 tonull
, 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 theservices.json
file.
The "ownerName"
property is an optional string from 1 to 64 bytes that specifies the account that owns an object.
The
"ownerName"
property is optional and has a dynamic default value.If the
"ownerName"
property is omitted or set tonull
, the server uses the value of the"defaultOwnerName"
property supplied during the "createSession"
action.If the
"defaultOwnerName"
property is not defined, the server uses the"admin"
as the owner name.The owner of an object has administrative rights over that object.
The
"ownerName"
property is a namespace for an object. You can think of it as a container of objects.The
"ownerName"
allows users to use any name for the objects they create — for example, a QA engineer may copy tables into their owner space to run a set of tests.It is common for a user to create their own copies of objects from other accounts for testing, troubleshooting, and fixing data. The copied objects can retain the same name because the
"ownerName"
distinguishes between them.The fully qualified name of an object is the
"databaseName"
,"ownerName"
, and the object's name, such as"tableName"
meaning a FairCom server may contain many tables with the name"mytable"
as long as each one is in a different database or in a different owner space.For example, an organization often creates different databases for different phases of the development lifecycle, such as dev, test, stage, ua, and prod. Each of these databases contains the same set of objects with the same names. Applications leave the
"databaseName"
out of their JSON actions and use the"defaultDatabaseName"
property to specify the target database.Queries and scripts are often written without specifying
"databaseName"
and/or"ownerName"
, allowing queries and scripts to work properly when run in different databases or in different schemas.
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 arraysThe 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
"result"
properties summaryProperty | 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 | |||
specifies the format of the data in the | string |
|
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"
.
"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.