UpdateTable() public method

Modifies the provisioned throughput settings, global secondary indexes, or DynamoDB Streams settings for a given table.

You can only perform one of the following operations at once:

  • Modify the provisioned throughput settings of the table.

  • Enable or disable Streams on the table.

  • Remove a global secondary index from the table.

  • Create a new global secondary index on the table. Once the index begins backfilling, you can use UpdateTable to perform other operations.

UpdateTable is an asynchronous operation; while it is executing, the table status changes from ACTIVE to UPDATING. While it is UPDATING, you cannot issue another UpdateTable request. When the table returns to the ACTIVE state, the UpdateTable operation is complete.

/// An error occurred on the server side. /// /// The number of concurrent table requests (cumulative number of tables in the CREATING, /// DELETING or UPDATING state) exceeds the maximum allowed /// of 10. /// /// /// /// Also, for tables with secondary indexes, only one of those tables can be in the CREATING /// state at any point in time. Do not attempt to create more than one such table simultaneously. /// /// /// /// The total limit of tables in the ACTIVE state is 250. /// /// /// The operation conflicts with the resource's availability. For example, you attempted /// to recreate an existing table, or tried to delete a table currently in the CREATING /// state. /// /// The operation tried to access a nonexistent table or index. The resource might not /// be specified correctly, or its status might not be ACTIVE. ///
public UpdateTable ( UpdateTableRequest request ) : UpdateTableResponse
request Amazon.DynamoDBv2.Model.UpdateTableRequest Container for the necessary parameters to execute the UpdateTable service method.
return Amazon.DynamoDBv2.Model.UpdateTableResponse
Example #1
0
        public void DataPlaneSamples()
        {
            {
                #region CreateTable Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Define table schema:
                //  Table has a hash-key "Author" and a range-key "Title"
                List<KeySchemaElement> schema = new List<KeySchemaElement>
                {
                    new KeySchemaElement
                    {
                        AttributeName = "Author", KeyType = "HASH"
                    },
                    new KeySchemaElement
                    {
                        AttributeName = "Title", KeyType = "RANGE"
                    }
                };

                // Define key attributes:
                //  The key attributes "Author" and "Title" are string types
                List<AttributeDefinition> definitions = new List<AttributeDefinition>
                {
                    new AttributeDefinition
                    {
                        AttributeName = "Author", AttributeType = "S"
                    },
                    new AttributeDefinition
                    {
                        AttributeName = "Title", AttributeType = "S"
                    }
                };

                // Define table throughput:
                //  Table has capacity of 20 reads and 50 writes
                ProvisionedThroughput throughput = new ProvisionedThroughput
                {
                    ReadCapacityUnits = 20,
                    WriteCapacityUnits = 50
                };

                // Configure the CreateTable request
                CreateTableRequest request = new CreateTableRequest
                {
                    TableName = "SampleTable",
                    KeySchema = schema,
                    ProvisionedThroughput = throughput,
                    AttributeDefinitions = definitions
                };

                // View new table properties
                TableDescription tableDescription = client.CreateTable(request).TableDescription;
                Console.WriteLine("Table name: {0}", tableDescription.TableName);
                Console.WriteLine("Creation time: {0}", tableDescription.CreationDateTime);
                Console.WriteLine("Item count: {0}", tableDescription.ItemCount);
                Console.WriteLine("Table size (bytes): {0}", tableDescription.TableSizeBytes);
                Console.WriteLine("Table status: {0}", tableDescription.TableStatus);

                // List table key schema
                List<KeySchemaElement> tableSchema = tableDescription.KeySchema;
                for (int i = 0; i < tableSchema.Count; i++)
                {
                    KeySchemaElement element = tableSchema[i];
                    Console.WriteLine("Key: Name = {0}, KeyType = {1}",
                        element.AttributeName, element.KeyType);
                }

                // List attribute definitions
                List<AttributeDefinition> attributeDefinitions = tableDescription.AttributeDefinitions;
                for (int i = 0; i < attributeDefinitions.Count; i++)
                {
                    AttributeDefinition definition = attributeDefinitions[i];
                    Console.WriteLine("Attribute: Name = {0}, Type = {1}",
                        definition.AttributeName, definition.AttributeType);
                }

                Console.WriteLine("Throughput: Reads = {0}, Writes = {1}",
                    tableDescription.ProvisionedThroughput.ReadCapacityUnits,
                    tableDescription.ProvisionedThroughput.WriteCapacityUnits);

                #endregion
            }

            {
                #region DescribeTable Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Create DescribeTable request
                DescribeTableRequest request = new DescribeTableRequest
                {
                    TableName = "SampleTable"
                };

                // Issue DescribeTable request and retrieve the table description
                TableDescription tableDescription = client.DescribeTable(request).Table;

                // View new table properties
                Console.WriteLine("Table name: {0}", tableDescription.TableName);
                Console.WriteLine("Creation time: {0}", tableDescription.CreationDateTime);
                Console.WriteLine("Item count: {0}", tableDescription.ItemCount);
                Console.WriteLine("Table size (bytes): {0}", tableDescription.TableSizeBytes);
                Console.WriteLine("Table status: {0}", tableDescription.TableStatus);
                // List table key schema
                List<KeySchemaElement> tableSchema = tableDescription.KeySchema;
                for (int i = 0; i < tableSchema.Count; i++)
                {
                    KeySchemaElement element = tableSchema[i];
                    Console.WriteLine("Key: Name = {0}, KeyType = {1}",
                        element.AttributeName, element.KeyType);
                }

                // List attribute definitions
                List<AttributeDefinition> attributeDefinitions = tableDescription.AttributeDefinitions;
                for (int i = 0; i < attributeDefinitions.Count; i++)
                {
                    AttributeDefinition definition = attributeDefinitions[i];
                    Console.WriteLine("Attribute: Name = {0}, Type = {1}",
                        definition.AttributeName, definition.AttributeType);
                }
                Console.WriteLine("Throughput: Reads = {0}, Writes = {1}",
                    tableDescription.ProvisionedThroughput.ReadCapacityUnits,
                    tableDescription.ProvisionedThroughput.WriteCapacityUnits);

                #endregion
            }

            {
                #region ListTables Paging Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                string startTableName = null;
                do
                {
                    // Configure ListTables request with the marker value
                    ListTablesRequest request = new ListTablesRequest
                    {
                        ExclusiveStartTableName = startTableName,
                    };

                    // Issue call
                    ListTablesResult result = client.ListTables(request);

                    // List retrieved tables
                    List<string> tables = result.TableNames;
                    Console.WriteLine("Retrieved tables: {0}",
                        string.Join(", ", tables));

                    // Update marker value from the result
                    startTableName = result.LastEvaluatedTableName;

                } while (!string.IsNullOrEmpty(startTableName)); // Test marker value

                #endregion
            }

            {
                #region ListTables NonPaging Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Issue call
                ListTablesResult result = client.ListTables();

                // List retrieved tables
                List<string> tables = result.TableNames;
                Console.WriteLine("Retrieved tables: {0}",
                    string.Join(", ", tables));

                #endregion
            }

            TableUtils.WaitUntilTableActive("SampleTable", TestClient);

            {
                #region UpdateTable Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Define new table throughput:
                //  Table will now have capacity of 40 reads and 50 writes
                ProvisionedThroughput throughput = new ProvisionedThroughput
                {
                    ReadCapacityUnits = 40,
                    WriteCapacityUnits = 50
                };

                // Compose the UpdateTable request
                UpdateTableRequest request = new UpdateTableRequest
                {
                    TableName = "SampleTable",
                    ProvisionedThroughput = throughput
                };

                // View new table properties
                TableDescription tableDescription = client.UpdateTable(request).TableDescription;
                Console.WriteLine("Table name: {0}", tableDescription.TableName);
                Console.WriteLine("Throughput: Reads = {0}, Writes = {1}",
                    tableDescription.ProvisionedThroughput.ReadCapacityUnits,
                    tableDescription.ProvisionedThroughput.WriteCapacityUnits);

                #endregion
            }

            TableUtils.WaitUntilTableActive("SampleTable", TestClient);

            {
                #region DeleteTable Sample

                // Create a client
                AmazonDynamoDBClient client = new AmazonDynamoDBClient();

                // Configure the DeleteTable request
                DeleteTableRequest request = new DeleteTableRequest
                {
                    TableName = "SampleTable"
                };

                // Issue DeleteTable request and retrieve the table description
                TableDescription tableDescription = client.DeleteTable(request).TableDescription;
                Console.WriteLine("Table name: {0}", tableDescription.TableName);
                Console.WriteLine("Table status: {0}", tableDescription.TableStatus);

                #endregion
            }

        }