Skip to main content

"deleteTables"

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 request

{
    "api":"db",
    "authToken": "replaceWithValidAuthtoken",
    "action": "deleteTables",
    "params": {
        "tableNames": [
            "test1"
        ]
    }
}
{
    "api": "db",
    "apiVersion": "1.0",
    "requestId": "2",
    "authToken": "replaceWithValidAuthtoken",
    "action": "deleteTables",
    "params": {
        "databaseName": "ctreeSQL",
        "ownerName": "admin",
        "tableNames": [
            "athlete",
            "all_types"
        ]
    },
    "responseOptions": {
        "binaryFormat": "hex",
        "dataFormat": "objects",
        "numberFormat": "string"
    },
    "debug": "max"
}
{
    "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": ""
}
{
    "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": {
            "authToken": "replaceWithValidAuthtoken",
            "api": "db",
            "action": "deleteTables",
            "params": {
                "databaseName": "ctreeSQL",
                "ownerName": "admin",
                "tableNames": [
                    "athlete",
                    "all_types"
                ]
            },
            "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 deleteTable JSON API action to delete tables

API actionsJSON DB APIjsonActiontable actionsdelete tabledeleteTables

The "params" property is an object that contains an action's parameters. Each action defines its own required and optional properties.

Properties summary

Table 1. "params" properties summary

Property

Description

Default

Type

Limits (inclusive)

databaseName

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

specifies the unique name of a schema in a database

""

string

1 to 64 bytes

tableNames

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 to null, 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 the services.json file.

The "ownerName" property is an optional string from 1 to 64 bytes that specifies the account that owns an object.

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

Table 2. "result" properties summary

Property

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

dataFormat

specifies the format of the data in the "data" property

string

"autoDetect"
"arrays"
"objects"


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

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

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.