The "truncateRecords" action deletes all records from a database table very quickly by deleting and recreating the data file. It must get an exclusive lock on the table before it can truncate it.
Request examples
Minimal
{
"action": "truncateRecords",
"params": {
"tableName": "test1",
"deleteAllRecords": true
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}Maximal
{
"api": "db",
"apiVersion": "1.0",
"requestId": "2",
"action": "truncateRecords",
"params": {
"databaseName": "ctreeSQL",
"ownerName": "admin",
"tableName": "test1",
"deleteAllRecords": true
},
"responseOptions": {
"binaryFormat": "hex",
"dataFormat": "objects",
"numberFormat": "string",
"includeFields": [],
"excludeFields": []
},
"debug": "max",
"authToken": "replaceWithAuthTokenFromCreateSession"
}
Response examples
Minimal
{
"errorCode": 0,
"errorMessage": "",
"authToken": "replaceWithAuthTokenFromCreateSession"
}Maximal
{
"requestId": "2",
"debugInfo": {
"request": {
"api": "db",
"action": "truncateRecords",
"params": {
"databaseName": "ctreeSQL",
"ownerName": "admin",
"tableName": "test1",
"deleteAllRecords": true
},
"apiVersion": "1.0",
"requestId": "2",
"responseOptions": {
"binaryFormat": "hex",
"dataFormat": "objects",
"numberFormat": "string",
"includeFields": [],
"excludeFields": []
},
"debug": "max",
"authToken": "replaceWithAuthTokenFromCreateSession"
},
"serverSuppliedValues": {
"databaseName": "ctreeSQL",
"ownerName": "admin"
},
"errorData": {
"errorData": null
},
"warnings": []
},
"errorCode": 0,
"errorMessage": "",
"authToken": "replaceWithAuthTokenFromCreateSession"
}
Properties
Request properties ("params")
| Property | Description | Default | Type | Limits (inclusive) |
|---|---|---|---|---|
databaseName |
The You specify this property when you want to use a different database instead of the default. Your session's account must have the appropriate privileges to access the code package. This property is useful because objects, such as tables and code packages, can have the same name in multiple databases. This feature allows you to create multiple environments in the same server and reuse the same JSON actions in each environment. For example, you can create It is an error to set If no default database is specified during |
Defaults to the session's "defaultDatabaseName" property |
string | 1 to 64 bytes |
deleteAllRecords |
The |
Required - No default value | Boolean |
|
ownerName |
The You specify this property when you want to use a different account instead of the default. Your session's account must have the appropriate privileges to access the code package. This property is useful because objects, such as tables and code packages, can have the same name in the same database as long as different accounts own each object. This feature allows you to create duplicate objects for different users on the same server and reuse the same JSON actions on those objects. For example, an administrator can copy objects from a production environment to her account so she can troubleshoot an issue using the same JSON actions, JavaScript, and SQL code. It is an error to set If no default owner is specified during |
Optional with default of the session's "defaultOwnerName" property |
string | 1 to 64 bytes |
tableName |
The See table name in System limits for the table naming requirements and limitations.
"params": {
"tableName": "ctreeTable"
} |
Required - No default value | string | 1 to 64 bytes |