Skip to main content

"deleteTables" (JSON Action)

JSON DB "deleteTables" action deletes tables

The "deleteTables" action deletes one or more tables in a single transaction. All specified tables are deleted, or none are.

Request examples

Minimal

{
    "api":"db",
    "action": "deleteTables",
    "params": {
        "tableNames": [
            "test1"
        ]
    },
    "authToken": "replaceWithAuthTokenFromCreateSession"
}
{
  "api": "db",
  "action": "deleteTables",
  "params": {
    "databaseName": "ctreeSQL",
    "ownerName": "admin",
    "tableNames": [
      "test2"
    ],
    "transactionId": null
  },
  "responseOptions": {
    "binaryFormat": "hex",
    "dataFormat": "objects",
    "numberFormat": "string"
  },
  "authToken": "replaceWithAuthTokenFromCreateSession",
  "apiVersion": "1.0",
  "requestId": "00000003",
  "debug": "max"
}

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",
        "data": [
            {
                "createRecByteIndex": false,
                "databaseName": "ctreeSQL",
                "fieldDelimiterValue": 0,
                "fields": [
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "id",
                        "nullable": false,
                        "scale": null,
                        "type": "bigint"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "changeId",
                        "nullable": true,
                        "scale": null,
                        "type": "bigint"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": 50,
                        "name": "name",
                        "nullable": true,
                        "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": null,
                        "immutableKeys": false,
                        "indexName": "id_pk",
                        "indexNumber": 0,
                        "ownerName": "admin",
                        "tableName": "test1",
                        "unique": true
                    }
                ],
                "ownerName": "admin",
                "padValue": 0,
                "path": ".\\ctreeSQL.dbs\\admin_test1.dat",
                "smallFile": false,
                "tableFileExtension": ".dat",
                "tableName": "test1",
                "totalRecordCount": 3,
                "transactionModel": "LOGTRANSACTIONS",
                "uid": 1169
            }
        ]
    },
    "errorCode": 0,
    "errorMessage": "",
    "authToken": "replaceWithAuthTokenFromCreateSession"
}
{
    "result": {
        "dataFormat": "objects",
        "data": [
            {
                "createRecByteIndex": false,
                "databaseName": "ctreeSQL",
                "fieldDelimiterValue": 0,
                "fields": [
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "id",
                        "nullable": false,
                        "scale": null,
                        "type": "bigint"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "changeId",
                        "nullable": true,
                        "scale": null,
                        "type": "bigint"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": 30,
                        "name": "name",
                        "nullable": true,
                        "scale": null,
                        "type": "varchar"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "ranking",
                        "nullable": false,
                        "scale": null,
                        "type": "smallint"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "birthDate",
                        "nullable": true,
                        "scale": null,
                        "type": "date"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": 32,
                        "name": "playerNumber",
                        "nullable": true,
                        "scale": 6,
                        "type": "number"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "livedPast2000",
                        "nullable": true,
                        "scale": null,
                        "type": "bit"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": 32,
                        "name": "earnings",
                        "nullable": true,
                        "scale": 4,
                        "type": "money"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": 500,
                        "name": "favoriteSaying",
                        "nullable": true,
                        "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": null,
                        "immutableKeys": false,
                        "indexName": "id_pk",
                        "indexNumber": 0,
                        "ownerName": "admin",
                        "tableName": "athlete",
                        "unique": true
                    }
                ],
                "ownerName": "admin",
                "padValue": 0,
                "path": ".\\ctreeSQL.dbs\\admin_athlete.dat",
                "smallFile": false,
                "tableFileExtension": ".dat",
                "tableName": "athlete",
                "totalRecordCount": 0,
                "transactionModel": "LOGTRANSACTIONS",
                "uid": 1177
            },
            {
                "createRecByteIndex": false,
                "databaseName": "ctreeSQL",
                "fieldDelimiterValue": 0,
                "fields": [
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "id",
                        "nullable": false,
                        "scale": null,
                        "type": "bigint"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "changeId",
                        "nullable": true,
                        "scale": null,
                        "type": "bigint"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": 65500,
                        "name": "nested_json_object_or_array",
                        "nullable": true,
                        "scale": null,
                        "type": "json"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "boolean_byte",
                        "nullable": true,
                        "scale": null,
                        "type": "bit"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "signed_int8",
                        "nullable": true,
                        "scale": null,
                        "type": "tinyint"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "signed_int16",
                        "nullable": true,
                        "scale": null,
                        "type": "smallint"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "signed_int32",
                        "nullable": true,
                        "scale": null,
                        "type": "integer"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "signed_int64",
                        "nullable": true,
                        "scale": null,
                        "type": "bigint"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "ieee_base2float32",
                        "nullable": true,
                        "scale": null,
                        "type": "real"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "ieee_base2float64",
                        "nullable": true,
                        "scale": null,
                        "type": "float"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": 32,
                        "name": "signed32digits_base10_left32right0",
                        "nullable": true,
                        "scale": 0,
                        "type": "number"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": 32,
                        "name": "signed32digits_base10_left0right32",
                        "nullable": true,
                        "scale": 32,
                        "type": "number"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": 32,
                        "name": "signed32digits_base10_left20right12",
                        "nullable": true,
                        "scale": 12,
                        "type": "number"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": 32,
                        "name": "signed32digits_base10_left30right2",
                        "nullable": true,
                        "scale": 2,
                        "type": "money"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": 32,
                        "name": "signed32digits_base10_left28right4",
                        "nullable": true,
                        "scale": 4,
                        "type": "money"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "date_yyyymmdd",
                        "nullable": true,
                        "scale": null,
                        "type": "date"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "time_hhmmss",
                        "nullable": true,
                        "scale": null,
                        "type": "time"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "datetime_yyyymmddthhmmss_nnnz",
                        "nullable": true,
                        "scale": null,
                        "type": "timestamp"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": 10,
                        "name": "fixed_string_10bytes",
                        "nullable": true,
                        "scale": null,
                        "type": "char"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": 65500,
                        "name": "variable_string_up_to_max65500bytes",
                        "nullable": true,
                        "scale": null,
                        "type": "varchar"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "variable_string_up_to_2GB",
                        "nullable": true,
                        "scale": null,
                        "type": "lvarchar"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": 10,
                        "name": "fixed_binary_10bytes",
                        "nullable": true,
                        "scale": null,
                        "type": "binary"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": 65500,
                        "name": "variable_binary_up_to_max65500bytes",
                        "nullable": true,
                        "scale": null,
                        "type": "varbinary"
                    },
                    {
                        "autoTimestamp": "none",
                        "defaultValue": null,
                        "length": null,
                        "name": "variable_binary_up_to_2GB",
                        "nullable": true,
                        "scale": null,
                        "type": "lvarbinary"
                    }
                ],
                "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": null,
                        "immutableKeys": false,
                        "indexName": "id_pk",
                        "indexNumber": 0,
                        "ownerName": "admin",
                        "tableName": "all_types",
                        "unique": true
                    }
                ],
                "ownerName": "admin",
                "padValue": 0,
                "path": ".\\ctreeSQL.dbs\\admin_all_types.dat",
                "smallFile": false,
                "tableFileExtension": ".dat",
                "tableName": "all_types",
                "totalRecordCount": 0,
                "transactionModel": "LOGTRANSACTIONS",
                "uid": 1181
            }
        ]
    },
    "requestId": "2",
    "debugInfo": {
        "request": {
            "api": "db",
            "action": "deleteTables",
            "params": {
                "databaseName": "ctreeSQL",
                "ownerName": "admin",
                "tableNames": [
                    "athlete",
                    "all_types"
                ]
            },
            "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 deleteTable JSON API action to delete tables

API actionsJSON DB APIJSON Actiontable actionsdelete tabledeleteTables

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. deleteTables "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

ownerName

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

""

string

1 to 64 bytes

tableNames

lists table names to delete.

Required - No default value

array

1 to 64 bytes

transactionId

(conditional) specifies the transaction ID if this action is to be included in a transaction.

""

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"
  }

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.

Table 2. deleteTables "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"
  }
}

You cannot modify a table while it is in use. When a table has no activity for a default of 2 seconds, it will be closed so you can modify it.

  • When a table is in use, the following actions return an error, such as -8 or 4012:

    • "alterTable"

    • "rebuildTables"

    • "deleteTables"

    • "createIndex"

    • "deleteIndexes"

    • "rebuildIndexes"

    • "runSqlStatements"

  • A table is in use when any account is performing one or more of the following actions with the table:

    • "insertRecords"

    • "updateRecords"

    • "deleteRecords"

    • "truncateRecords"

    • "getRecords..."

    • Has open cursors on the table.

    • Has open transactions on the table (such "createTransaction").

  • Modify the SQL_IDLE_WAKE startup configuration setting to change the number of seconds the server waits before closing a table. A larger number keeps the table open longer for better performance. A smaller number allows you to modify the table sooner.

  • Modify the SQL_IDLE_WAKE startup configuration setting to change the number of tables the server keeps open after they are no longer being actively used. A larger number caches more tables and improves performance. A smaller number allows you to modify tables sooner.