"deleteDatabase" (JSON Action)
JSON DB "deleteDatabase" action deletes a database
Request examples
Minimal
{
"api":"db",
"action": "deleteDatabase",
"params": {
"databaseName": "test_db_min"
},
"requestId": "1",
"authToken": "replaceWithAuthTokenFromCreateSession"
}{
"api": "db",
"apiVersion": "1.0",
"requestId": "00000022",
"action": "deleteDatabase",
"params": {
"databaseName": "test_db_max"
},
"responseOptions": {
"binaryFormat": "hex",
"dataFormat": "objects",
"numberFormat": "string"
},
"debug": "max",
"authToken": "replaceWithAuthTokenFromCreateSession"
}Note
If the target object does not exist, the response returns success, and the debug property contains a warning that the object was not found.
Minimal
{
"result": {
"dataFormat": "objects",
"fields": [
{
"name": "databaseName",
"type": "varchar",
"length": 8192,
"scale": null,
"defaultValue": null,
"nullable": false,
"primaryKey": 0,
"autoValue": "none"
},
{
"name": "path",
"type": "varchar",
"length": 8192,
"scale": null,
"defaultValue": null,
"nullable": false,
"primaryKey": 0,
"autoValue": "none"
},
{
"name": "uid",
"type": "bigint",
"length": null,
"scale": null,
"defaultValue": null,
"nullable": false,
"primaryKey": 0,
"autoValue": "none"
}
],
"data": [
{
"databaseName": "test_db_min",
"path": ".\\test_db_min.dbs\\SQL_SYS",
"uid": 1005
}
]
},
"requestId": "1",
"debugInfo": {
"request": {
"api": "db",
"action": "deleteDatabase",
"params": {
"databaseName": "test_db_min"
},
"requestId": "00000014",
"debug": "max",
"authToken": "replaceWithAuthTokenFromCreateSession"
},
"serverSuppliedValues": {
"databaseName": null,
"ownerName": null
},
"errorData": {
"errorData": null
},
"warnings": []
},
"errorCode": 0,
"errorMessage": "",
"authToken": "replaceWithAuthTokenFromCreateSession"
}
{
"result": {
"dataFormat": "objects",
"fields": [
{
"name": "databaseName",
"type": "varchar",
"length": 8192,
"scale": null,
"defaultValue": null,
"nullable": false,
"primaryKey": 0,
"autoValue": "none"
},
{
"name": "path",
"type": "varchar",
"length": 8192,
"scale": null,
"defaultValue": null,
"nullable": false,
"primaryKey": 0,
"autoValue": "none"
},
{
"name": "uid",
"type": "bigint",
"length": null,
"scale": null,
"defaultValue": null,
"nullable": false,
"primaryKey": 0,
"autoValue": "none"
}
],
"data": [
{
"databaseName": "test_db_max",
"path": "c:\\\\test_db_max.dbs\\SQL_SYS",
"uid": 1007
}
]
},
"requestId": "2",
"debugInfo": {
"request": {
"api": "db",
"action": "deleteDatabase",
"params": {
"databaseName": "test_db_maxasdfasdf"
},
"apiVersion": "1.0",
"requestId": "2",
"responseOptions": {
"binaryFormat": "hex",
"dataFormat": "objects",
"numberFormat": "string"
},
"debug": "max",
"authToken": "replaceWithAuthTokenFromCreateSession"
},
"serverSuppliedValues": {
"databaseName": null,
"ownerName": null
},
"errorData": {
"errorData": null
},
"warnings": []
},
"errorCode": 0,
"errorMessage": "",
"authToken": "replaceWithAuthTokenFromCreateSession"
}
Use the deleteDatabase API action to delete a database
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) |
|---|---|---|---|---|
specifies the name of a database to be deleted. | Required - No default value | string | 1 to 64 bytes | |
(optional) identifies a transaction in which this action will be included. |
| string | 0 to 255 bytes |
The "databaseName" property is a string that identifies the name of the target database.
A zero-length
"databaseName"is invalid.Its limits are from 1 to 64 bytes.
"result" properties summaryProperty | Description | Type | Limits (inclusive) | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
is an array of objects or arrays that the server returns that identify the database's characteristics. It is an empty array when no results are available. | array | Its contents are determined by the action | ||||||||||||||||||||||
identifies the format of the data in the | string |
| ||||||||||||||||||||||
contains an array of objects returned by the server, where each object identifies the attributes of a field in the table. | array | |||||||||||||||||||||||
| identifies when and how the server automatically sets the field value. | string |
| |||||||||||||||||||||
| identifies the default value of the field. | string | 0 to 65,500 bytes | |||||||||||||||||||||
| identifies the length of the field. | integer |
| |||||||||||||||||||||
| identifies the name of the field. | string | 0 to 64 bytes | |||||||||||||||||||||
| if | Boolean |
| |||||||||||||||||||||
| if > 0, identifies the ordinal position of the field in a table's primary key. | integer |
| |||||||||||||||||||||
| identifies the number of places to the right of the decimal point if the field is type | integer |
| |||||||||||||||||||||
| identifies the type of the field. See Data types. | string |
|
This optional property indicates when and how the server automatically sets the field value.
Only one of these values is allowed per field.
"none"indicates that the server does not automatically set the field's value."incrementOnInsert"indicates that the server automatically increments a field’s value each time the server inserts a new record. It applies to fields that are of the type of decimal or one of the integer types, such as"bigint". Only one field per table can have this attribute. The server returns an error when assigning this attribute to multiple fields. The JSON DB API automatically creates the"id"field as an"incrementOnInsert"field. If you apply this attribute to another field, it becomes the only automatically incremented field in the table. If you want that field to be the primary key, assign"primaryKey": 1to it."timestampOnInsert"indicates that the server automatically sets a field’s value to the current date and time of an insert. It applies only to fields with a type of"timestamp".Note
If you attempt to insert a record and specify a timestamp for a field that has
"autoValue"set to"timestampOnInsert", the timestamp you specified is ignored, and the current date and time are assigned to the field."timestampOnUpdate"indicates that the server automatically sets a field’s value to the current date and time of an update. This setting applies only to timestamp fields."timestampOnUpdateAndInsert"indicates that the server automatically sets a field’s value to the current date and time of an insert and an update. It applies only to fields with a type of"timestamp"."changeId"indicates the server uses the field for optimistic locking. The server automatically sets the field's value to the internal transaction number used during the last update of the record. This value changes each time the server updates the record. A table may only have one change tracking field. The field type must be"bigint".The JSON DB API automatically creates a
"changeid"field with change-tracking functionality.Change tracking is optional in the CTDB and ISAM APIs. The application must create a 64-bit integer field and assign change-tracking functionality to it.
Request Example
"fields": [
{
"name": "signed_int32",
"type": "integer",
"autoValue": "incrementOnInsert"
}
]
Response Example
{
"result": {
"dataFormat": "objects",
"data": [
{
"changeIdField": "changeId",
"createRecByteIndex": false,
"databaseName": "ctreeSQL",
"fieldDelimiterValue": 0,
"fields": [
{
"autoValue": "incrementOnInsert",
"defaultValue": null,
"length": null,
"name": "signed_int32",
"nullable": true,
"primaryKey": 0,
"scale": null,
"type": "integer"
}
]
}
]
},
"errorCode": 0,
"errorMessage": "",
"authToken": "replaceWithAuthTokenFromCreateSession"
}
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".
"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 "fields" property is an array of objects. It is required when creating a table. Each object in the array defines a field by specifying its properties.
Example
"fields": [
{
"autoValue": "none",
"name": "name",
"type": "varchar",
"length": 50,
"scale": null,
"defaultValue": null,
"nullable": false
}
]