Menu
Amazon DynamoDB
Getting Started Guide (API Version 2012-08-10)

Step 5: (Optional) Delete the Table

To delete the Movies table:

  1. Copy the following program into the Program.cs file, replacing its current contents.

    using System;
    using System.Text;
    
    using Amazon.DynamoDBv2;
    using Amazon.DynamoDBv2.Model;
    
    namespace DynamoDB_intro
    {
      class Program
      {
        static void Main( string[ ] args )
        {
          // Get an AmazonDynamoDBClient for the local DynamoDB database
          AmazonDynamoDBClient client = GetLocalClient( );
    
          try { client.DeleteTable( "Movies" ); }
          catch( Exception ex )
          {
            Console.WriteLine( "\n Error: the \'Movies\" table could not be deleted!\n    Reason: " + ex.Message );
            goto PauseForDebugWindow;
          }
          Console.WriteLine( "\n Deleted the \'Movies\" table successfully!" );
    
          // Keep the console open if in Debug mode...
    PauseForDebugWindow:
          Console.Write( "\n\n ...Press any key to continue" );
          Console.ReadKey( );
          Console.WriteLine( );
        }
    
        public static AmazonDynamoDBClient GetLocalClient( )
        {
          // First, set up a DynamoDB client for DynamoDB Local
          AmazonDynamoDBConfig ddbConfig = new AmazonDynamoDBConfig( );
          ddbConfig.ServiceURL = "http://localhost:8000";
          AmazonDynamoDBClient client;
          try { client = new AmazonDynamoDBClient( ddbConfig ); }
          catch( Exception ex )
          {
            Console.WriteLine( "\n Error: failed to create a DynamoDB client; " + ex.Message );
            return ( null );
          }
          return ( client );
        }
      }
    }
    
  2. Compile and run the program.