Delete columns in your table

Alter the schema of your database tables by removing columns using the DataStax Astra DB REST API.

If you find an attribute is no longer required in a table, you can remove a column by sending a DELETE request to delete the column. All column data will be deleted along with the column schema. Use the Delete a column endpoint to remove a column from a table you created previously.

Drop a single column

Drop the column email from the table users that was added in Add columns to a table.

Send a DELETE request to /api/rest/v2/schemas/keyspaces/{keyspace_name}/tables/{table_name}/columns/{column_name} to delete a column. All column data will be deleted along with the column schema.

curl -s --location \
--request DELETE http://$ASTRA_CLUSTER_ID-$ASTRA_REGION.apps.astra.datastax.com/api/rest/v2/schemas/keyspaces/users_keyspace/tables/users/columns/email \
--header "X-Cassandra-Token: $ASTRA_DB_APPLICATION_TOKEN" \
--header "Content-Type: application/json"

Note that the URL includes the keyword columns followed by the column name, in this case, email. Each column that you wish to drop must be executed with a separate command.

  1. Run the cURL call.

If the call is successful, a 204 message is returned.