"describeTables" (JSON Action)
JSON DB "describeTables" action returns a complete set of metadata about one or more specified tables
Request examples
Minimal
{
"api": "db",
"action": "describeTables",
"params": {
"tableNames": [
"test1"
]
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}
{
"api": "db",
"action": "describeTables",
"params": {
"databaseName": "ctreeSQL",
"ownerName": "admin",
"tableNames": [
"all_types"
],
"transactionId": null
},
"responseOptions": {
"binaryFormat": "hex",
"dataFormat": "objects",
"numberFormat": "string"
},
"debug": "max",
"authToken": "replaceWithAuthTokenFromCreateSession",
"apiVersion": "1.0",
"requestId": "00000004"
}
Minimal
{
"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": {
"api": "db",
"action": "describeTables",
"params": {
"tableNames": [
"test1"
]
},
"debug": "max",
"authToken": "replaceWithAuthTokenFromCreateSession"
},
"serverSuppliedValues": {
"databaseName": "ctreeSQL",
"ownerName": "admin"
},
"errorData": {
"errorData": null
},
"warnings": []
},
"errorCode": 0,
"errorMessage": "",
"authToken": "replaceWithAuthTokenFromCreateSession"
}
{
"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": {
"api": "db",
"action": "describeTables",
"params": {
"databaseName": "ctreeSQL",
"ownerName": "admin",
"tableNames": [
"athlete"
]
},
"apiVersion": "1.0",
"requestId": "2",
"responseOptions": {
"dataFormat": "objects"
},
"debug": "max",
"authToken": "replaceWithAuthTokenFromCreateSession"
},
"serverSuppliedValues": {
"databaseName": "ctreeSQL",
"ownerName": "admin"
},
"errorData": {
"errorData": null
},
"warnings": []
},
"errorCode": 0,
"errorMessage": "",
"authToken": "replaceWithAuthTokenFromCreateSession"
}
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 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.
"params" properties summaryProperty | Description | Default | Type | Limits (inclusive) |
|---|---|---|---|---|
(optional) specifies the name of a database. | Defaults to the | string | 1 to 64 bytes | |
(optional) specifies the unique name of a schema in a database. |
| string | 1 to 64 bytes | |
specifies a list of table names to return in the response message. | Required - No default value | array | 1 to 64 bytes | |
(conditional) specifies a transaction ID. If you are running describeTable while a transaction is creating a table, you can include the transaction ID, and the new table details will be shown 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 tonull, 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 theservices.jsonfile.
"params": {
"databaseName": "mainDatabase"
}
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 "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.
"result" properties summaryProperty | Description | Type | Limits (inclusive) | |||
|---|---|---|---|---|---|---|
(conditional) specifies the changeIdField if it was changed from the default. | string | 1 to 64 bytes | ||||
specifies an array containing one object for each table specified in the user's request | array | Only tables that exist will be listed. | ||||
identifies the format of the data in the | string |
| ||||
(conditional) specifies values of the fields used to form a multi-field primary key. It is mutually exclusive with | array of arrays | |||||
(conditional) contains an array of strings, each string is the name of a field that is part of a multi-field primary key. | array |
This property's value designates the name of the field used for change-tracking functionality if you are not using the "changeId" field for change tracking.
"createTable" automatically creates the "changeId" field to hold the change tracking number used for optimistic locking. Using the "changeId" field for optimistic locking is a best practice.
However, if you use the name "changeId" for another purpose, you can use the "changeIdField" property to designate a different field as the change tracking number field.
Request example
"params": {
"changeIdField": "changetrackingid"
}
The "data" property specifies an array or object that the server returns, such as records returned by a query. This property is always included in a response but will return an empty array when no results are available.
If you specify a table in your request that does not exist, the "data" property will not include an entry for that table. Rather, the "warnings" property will include a message specifying which tables were not found.
"warnings": [
{
"code": 4023,
"message": "Table 'test2' not found"
},
{
"code": 4023,
"message": "Table 'aidmn' not found"
},
{
"code": 4023,
"message": "Table 'finances' not found"
}
],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".
"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"
}
}
The "primaryKeys" property is an array of arrays containing key-value pairs. The default value is ""null" ,but it is required if the "ids" property is omitted. It is used to specify search criteria and to show the results found.
"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, enabling the server to retrieve multiple records simultaneously.
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" }
]
]
This optional property specifies the fields of the table’s primary key when multiple fields are combined to form the primary key.
Note
The best practice is not to use the "primaryKeyFields" or "primaryKey" properties, so the "createTable" action will automatically create a primary key field named "id" with a unique index named "id_pk".
The order of fields in this property is the order of fields in the primary key index. The "fields" property contains the name and type of each field that is specified in the "primaryKeyFields" array.
A primary key with multiple fields has an index named "pk". If you specify just one field, the index is named "<fieldname>_pk".
If only one field is used as the primary key, the "primaryKey" property defines the primary key.
Note
The "primaryKeyFields" and "primaryKey" properties cannot be used together.
Example
"primaryKeyFields": [
"a",
"b",
"c"
],
"fields": [
{
"name": "a",
"type": "tinyint"
},
{
"name": "b",
"type": "smallint"
},
{
"name": "c",
"type": "integer"
}
]