DeleteTable

Description

The DeleteTable function deletes a table and all items present in the table.

For more information, see DeleteTable.

Category

History

ColdFusion (2021 release): Added this function.

Syntax

serviceHandle.deleteTable(requestParameters)

Parameters

See request parameters of DeleteTable.

Example

<cfscript> 
 cred = { 
    "credentialAlias" : "myalias", 
    "vendorName" : "AWS", 
    "region" : "us-east-2", 
    "secretAccessKey" : "xxxxx", 
    "accessKeyId" : "xxxx" 
  } 
  config = { 
    "serviceName" = "DYNAMODB" 
  } 
  dynamo = getCloudService(cred, config) 
  tableName="YearlyProductCatalog" 
  // create a table 
  createTableStruct={ 
      "TableName": "#tableName#", 
      "KeySchema": [ 
          { 
              "AttributeName": "id","KeyType": "HASH" 
          }, 
          { 
              "AttributeName": "title","KeyType": "RANGE" 
          } 
      ], 
      "AttributeDefinitions": [ 
          { 
              "AttributeName": "id", 
              "AttributeType": "N" 
          }, 
          { 
              "AttributeName": "title", 
              "AttributeType": "S" 
          } 
      ], 
      "ProvisionedThroughput": { 
          "ReadCapacityUnits": 10, 
          "WriteCapacityUnits": 10 
      } 
  } 
 
  dynamo.createTable(createTableStruct) 
  sleep(20000) 
 
  // insert an item 
  putItemStruct = { 
      "TableName": "#tableName#", 
      "Item":{ 
          "id": {"N": 550}, 
          "title": {"S": "My Books Title"} 
      }, 
      "ReturnValues": "NONE" 
  } 
  dynamo.putItem(putItemStruct,{"hasType": true}) 
 
  // delete the table 
  deleteTableStruct={ 
    "TableName": "#tableName#" 
  } 
  try{ 
    deleteResponse=dynamo.deleteTable(deleteTableStruct) 
    writeOutput("Table deleted successfully") 
    writeDump(deleteResponse) 
  } 
  catch (any e){ 
    writeOutput("Unable to delete the table") 
    writeDump(e) 
  } 
</cfscript> 

Output

DeleteTable output
DeleteTable output

Get help faster and easier

New user?