Skip to main content

"rebuildTables" (JSON Action)

JSON DB "rebuildTables" action rebuilds specified tables

  • "rebuildTables" executes the rebuild on each table in the order they are specified, so if an error occurs, all tables before the table causing the error are rebuilt, and tables following the table causing the error are not.

  • This action is not transactional.

  • As many tables as possible in the list are rebuilt.

  • A failure to rebuild one or more tables does not stop others from being rebuilt.

  • If a table contains many records, the rebuild process may take a while.

Request examples

Minimal

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

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
      }
    ]
  },
  "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": 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
      }
    ]
  },
  "requestId": "2",
  "debugInfo": {
    "request": {
      "api": "db",
      "action": "rebuildTables",
      "params": {
        "databaseName": "ctreeSQL",
        "ownerName": "admin",
        "tableNames": [
          "test1"
        ]
      },
      "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 rebuildTables JSON API action to create a new table in a FairCom database

API actionsJSON DB APIJSON Actiontable actionsrebuild tablerebuildTables

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

1 to 64 bytes

ownerName

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

""

string

1 to 64 bytes

tableNames

specifies the names of tables to rebuild.

Required - No default value

string array

1 to 64 bytes per string

transactionId

(optional) specifies a transaction ID.

""

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


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.