Delete rows

Finds rows in a table using filter clauses, and then deletes those rows.

If you don’t use a filter, or if you use an empty filter, then this method deletes all rows in the table.

Deleting rows produces tombstones. Excessive tombstones can impact query performance.

For general information about working with tables and rows, see About tables with the Data API.

Ready to write code? See the examples for this method to get started. If you are new to the Data API, check out the quickstart.

Result

  • Python

  • TypeScript

  • Java

  • C#

  • curl

Deletes rows that match the specified parameters. If no rows match the specified parameters, this method does not delete any rows.

Does not return anything.

Deletes rows that match the specified parameters. If no rows match the specified parameters, this method does not delete any rows.

Returns a promise that resolves once the operation completes.

Deletes rows that match the specified parameters. If no rows match the specified parameters, this method does not delete any rows.

Does not return anything.

Deletes rows that match the specified parameters. If no rows match the specified parameters, this method does not delete any rows.

Does not return anything.

Deletes rows that match the specified parameters. If no rows match the specified parameters, this method does not delete any rows.

Always returns a status.deletedCount of -1, regardless of whether a row was found and deleted.

Example response:

{
  "status": {
    "deletedCount": -1
  }
}

Parameters

  • Python

  • TypeScript

  • Java

  • C#

  • curl

Use the delete_many method, which belongs to the astrapy.Table class.

Method signature
delete_many(
  filter: Dict[str, Any],
  *,
  general_method_timeout_ms: int,
  request_timeout_ms: int,
  timeout_ms: int,
) -> None
Name Type Summary

filter

dict

The filter criteria, defined using the Data API filter syntax.

If not empty, the filter depends on the table’s primary key definition:

  • For tables with a single-column primary key: the filter must include the primary key, and it cannot include any other columns.

  • For tables with a composite primary key: the filter must include all partition keys, and it cannot include any columns outside of the primary key definition.

  • For tables with a compound primary key: the filter must include all partition keys. It can include optional clustering keys, but it cannot include columns outside of the primary key definition.

    If you include clustering keys, you must include them in the order specified in the primary key definition. You can omit clustering keys, but you cannot skip any clustering keys. For example, if you have three clustering keys, a, b, and c, then you can include a and omit b and c. However, if you include b, then you must also include a.

    Additionally, clustering keys allow only the $eq operator, with the exception of the last clustering key in the table’s primary key definition, which allows $eq, $ne, or range operators ($gt, $gte, $lt, and $lte). For example, if your table has three clustering keys, a, b, and c, then you can only use range operators with c.

If you don’t use a filter, or if you use an empty filter, then this method deletes all rows in the table.

general_method_timeout_ms

int

Optional. The maximum time, in milliseconds, that the client should wait for the underlying HTTP request.

This parameter is aliased as request_timeout_ms and timeout_ms for convenience.

Default: The default value for the table. This default is 30 seconds unless you specified a different default when you initialized the Table or DataAPIClient object. For more information, see Timeout options.

Use the deleteMany method, which belongs to the Table class.

Method signature
async deleteMany(
  filter: TableFilter<Schema>,
  options?: {
    timeout?: number | TimeoutDescriptor,
  },
): void
Name Type Summary

filter

TableFilter

The filter criteria, defined using the Data API filter syntax.

If not empty, the filter depends on the table’s primary key definition:

  • For tables with a single-column primary key: the filter must include the primary key, and it cannot include any other columns.

  • For tables with a composite primary key: the filter must include all partition keys, and it cannot include any columns outside of the primary key definition.

  • For tables with a compound primary key: the filter must include all partition keys. It can include optional clustering keys, but it cannot include columns outside of the primary key definition.

    If you include clustering keys, you must include them in the order specified in the primary key definition. You can omit clustering keys, but you cannot skip any clustering keys. For example, if you have three clustering keys, a, b, and c, then you can include a and omit b and c. However, if you include b, then you must also include a.

    Additionally, clustering keys allow only the $eq operator, with the exception of the last clustering key in the table’s primary key definition, which allows $eq, $ne, or range operators ($gt, $gte, $lt, and $lte). For example, if your table has three clustering keys, a, b, and c, then you can only use range operators with c.

If you don’t use a filter, or if you use an empty filter, then this method deletes all rows in the table.

options.timeout

number | TimeoutDescriptor

Optional. A timeout to impose on the underlying API request.

Use the deleteMany method, which belongs to the com.datastax.astra.client.tables.Table class.

Method signature
void deleteMany(Filter filter)
void deleteMany(
  Filter filter,
  TableDeleteManyOptions options
)
Name Type Summary

filter

Filter

The filter criteria, defined using the Data API filter syntax.

If not empty, the filter depends on the table’s primary key definition:

  • For tables with a single-column primary key: the filter must include the primary key, and it cannot include any other columns.

  • For tables with a composite primary key: the filter must include all partition keys, and it cannot include any columns outside of the primary key definition.

  • For tables with a compound primary key: the filter must include all partition keys. It can include optional clustering keys, but it cannot include columns outside of the primary key definition.

    If you include clustering keys, you must include them in the order specified in the primary key definition. You can omit clustering keys, but you cannot skip any clustering keys. For example, if you have three clustering keys, a, b, and c, then you can include a and omit b and c. However, if you include b, then you must also include a.

    Additionally, clustering keys allow only the $eq operator, with the exception of the last clustering key in the table’s primary key definition, which allows $eq, $ne, or range operators ($gt, $gte, $lt, and $lte). For example, if your table has three clustering keys, a, b, and c, then you can only use range operators with c.

If you don’t use a filter, or if you use an empty filter, then this method deletes all rows in the table.

options

TableDeleteManyOptions

General API options for this operation, including the timeout.

Use the DeleteManyAsync method, which belongs to the Table class. You can also use DeleteMany, which is the synchronous version of the method.

Method signature
public Task DeleteManyAsync(
  TableFilter<T> filter, TableDeleteManyOptions options = null
);

For best performance, filter and sort on indexed columns, partition keys, and clustering keys.

Filtering on non-indexed columns is inefficient and resource-intensive, especially for large datasets. With the Data API clients, such operations can hit the client timeout limit before the underlying HTTP operation is complete. If you filter on non-indexed columns, the Data API will give a warning.

An empty filter or omitted filter may also result in an inefficient and long-running operation.

Additionally, the Data API can perform in-memory sorting, depending on the columns you sort on, the table’s partitioning structure, and whether the sorted columns are indexed. In-memory sorts can have performance implications.

Name Type Summary

filter

TableFilter

The filter criteria, defined using the Data API filter syntax.

If no filter or an empty filter is used, all rows are deleted.

If not empty, the filter depends on the table’s primary key definition:

  • For tables with a single-column primary key: the filter must include the primary key, and it cannot include any other columns.

  • For tables with a composite primary key: the filter must include all partition keys, and it cannot include any columns outside of the primary key definition.

  • For tables with a compound primary key: the filter must include all partition keys. It can include optional clustering keys, but it cannot include columns outside of the primary key definition.

    If you include clustering keys, you must include them in the order specified in the primary key definition. You can omit clustering keys, but you cannot skip any clustering keys. For example, if you have three clustering keys, a, b, and c, then you can include a and omit b and c. However, if you include b, then you must also include a.

    Additionally, clustering keys allow only the $eq operator, with the exception of the last clustering key in the table’s primary key definition, which allows $eq, $ne, or range operators ($gt, $gte, $lt, and $lte). For example, if your table has three clustering keys, a, b, and c, then you can only use range operators with c.

If you don’t use a filter, or if you use an empty filter, then this method deletes all rows in the table.

options

TableDeleteManyOptions

Optional. General API options for this operation, including the timeout. For more information and examples, see Customize API interaction.

Use the deleteMany command.

Command signature
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME/TABLE_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
  "deleteMany": {
    "filter": FILTER,
  }
}'
Name Type Summary

filter

object

The filter criteria, defined using the Data API filter syntax.

If not empty, the filter depends on the table’s primary key definition:

  • For tables with a single-column primary key: the filter must include the primary key, and it cannot include any other columns.

  • For tables with a composite primary key: the filter must include all partition keys, and it cannot include any columns outside of the primary key definition.

  • For tables with a compound primary key: the filter must include all partition keys. It can include optional clustering keys, but it cannot include columns outside of the primary key definition.

    If you include clustering keys, you must include them in the order specified in the primary key definition. You can omit clustering keys, but you cannot skip any clustering keys. For example, if you have three clustering keys, a, b, and c, then you can include a and omit b and c. However, if you include b, then you must also include a.

    Additionally, clustering keys allow only the $eq operator, with the exception of the last clustering key in the table’s primary key definition, which allows $eq, $ne, or range operators ($gt, $gte, $lt, and $lte). For example, if your table has three clustering keys, a, b, and c, then you can only use range operators with c.

If you don’t use a filter, or if you use an empty filter, then this method deletes all rows in the table.

Examples

The following examples demonstrate how to delete rows in a table.

Delete a row by primary key

If the filter specifies the full primary key, only the row matching that full primary key is deleted.

In the following example, the table has a composite primary key with the columns title and author.

For more information, see Primary keys in tables and Filter operators for tables.

  • Python

  • TypeScript

  • Java

  • C#

  • curl

from astrapy import DataAPIClient
from astrapy.authentication import UsernamePasswordTokenProvider
from astrapy.constants import Environment

# Get an existing table
client = DataAPIClient(environment=Environment.HCD)
database = client.get_database(
    "API_ENDPOINT",
    token=UsernamePasswordTokenProvider("USERNAME", "PASSWORD"),
)
table = database.get_table("TABLE_NAME", keyspace="KEYSPACE_NAME")

# Delete rows
table.delete_many(
    {"title": "Hidden Shadows of the Past", "author": "John Anthony"}
)
import {
  DataAPIClient,
  UsernamePasswordTokenProvider,
} from "@datastax/astra-db-ts";

// Get an existing table
const client = new DataAPIClient({ environment: "hcd" });
const database = client.db("API_ENDPOINT", {
  token: new UsernamePasswordTokenProvider("USERNAME", "PASSWORD"),
});
const table = database.table("TABLE_NAME", {
  keyspace: "KEYSPACE_NAME",
});

// Delete rows
(async function () {
  const result = await table.deleteMany({
    title: "Hidden Shadows of the Past",
    author: "John Anthony",
  });

  console.log(result);
})();
import com.datastax.astra.client.DataAPIClients;
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.core.query.Filters;
import com.datastax.astra.client.tables.Table;
import com.datastax.astra.client.tables.definition.rows.Row;

public class Example {

  public static void main(String[] args) {
    // Get an existing table
    Table<Row> table =
        DataAPIClients.clientHCD("USERNAME", "PASSWORD")
            .getDatabase("API_ENDPOINT", "KEYSPACE_NAME")
            .getTable("TABLE_NAME");

    // Delete rows
    Filter filter =
        Filters.and(
            Filters.eq("title", "Hidden Shadows of the Past"),
            Filters.eq("author", "John Anthony"));

    table.deleteMany(filter);
  }
}
using DataStax.AstraDB.DataApi;
using DataStax.AstraDB.DataApi.Core;
using DataStax.AstraDB.DataApi.Tables;

namespace Examples;

public class Program
{
  static async Task Main()
  {
    // Get an existing table
    var client = new DataAPIClient(
      new CommandOptions() { Destination = DataAPIDestination.HCD }
    );

    var database = client.GetDatabase(
      "API_ENDPOINT",
      DataAPIClient.UsernamePasswordTokenProvider(
        "USERNAME",
        "PASSWORD"
      ),
      "KEYSPACE_NAME"
    );

    var table = database.GetTable("TABLE_NAME");

    // Delete rows
    var filterBuilder = Builders<Row>.TableFilter;
    var filter = filterBuilder.And(
      filterBuilder.Eq("title", "Hidden Shadows of the Past"),
      filterBuilder.Eq("author", "John Anthony")
    );

    await table.DeleteManyAsync(filter);
  }
}
curl -sS -L -X POST "API_ENDPOINT/v1/KEYSPACE_NAME/TABLE_NAME" \
  --header "Token: APPLICATION_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "deleteMany": {
    "filter": {
      "title": "Hidden Shadows of the Past",
      "author": "John Anthony"
    }
  }
}'

Delete rows in a table with a single-column primary key

If the table has a single-column primary key, the filter must include the column in the primary key, and it cannot include any other columns.

In the following example, the table has a single-column primary key with the column title.

For more information, see Primary keys in tables and Filter operators for tables.

  • Python

  • TypeScript

  • Java

  • C#

  • curl

from astrapy import DataAPIClient
from astrapy.authentication import UsernamePasswordTokenProvider
from astrapy.constants import Environment

# Get an existing table
client = DataAPIClient(environment=Environment.HCD)
database = client.get_database(
    "API_ENDPOINT",
    token=UsernamePasswordTokenProvider("USERNAME", "PASSWORD"),
)
table = database.get_table("TABLE_NAME", keyspace="KEYSPACE_NAME")

# Delete rows
table.delete_many(
    {
        "title": "Hidden Shadows of the Past",
    }
)
import {
  DataAPIClient,
  UsernamePasswordTokenProvider,
} from "@datastax/astra-db-ts";

// Get an existing table
const client = new DataAPIClient({ environment: "hcd" });
const database = client.db("API_ENDPOINT", {
  token: new UsernamePasswordTokenProvider("USERNAME", "PASSWORD"),
});
const table = database.table("TABLE_NAME", {
  keyspace: "KEYSPACE_NAME",
});

// Delete rows
(async function () {
  const result = await table.deleteMany({
    title: "Hidden Shadows of the Past",
  });

  console.log(result);
})();
import com.datastax.astra.client.DataAPIClients;
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.core.query.Filters;
import com.datastax.astra.client.tables.Table;
import com.datastax.astra.client.tables.definition.rows.Row;

public class Example {

  public static void main(String[] args) {
    // Get an existing table
    Table<Row> table =
        DataAPIClients.clientHCD("USERNAME", "PASSWORD")
            .getDatabase("API_ENDPOINT", "KEYSPACE_NAME")
            .getTable("TABLE_NAME");

    // Delete rows
    Filter filter = Filters.eq("title", "Hidden Shadows of the Past");

    table.deleteMany(filter);
  }
}
using DataStax.AstraDB.DataApi;
using DataStax.AstraDB.DataApi.Core;
using DataStax.AstraDB.DataApi.Tables;

namespace Examples;

public class Program
{
  static async Task Main()
  {
    // Get an existing table
    var client = new DataAPIClient(
      new CommandOptions() { Destination = DataAPIDestination.HCD }
    );

    var database = client.GetDatabase(
      "API_ENDPOINT",
      DataAPIClient.UsernamePasswordTokenProvider(
        "USERNAME",
        "PASSWORD"
      ),
      "KEYSPACE_NAME"
    );

    var table = database.GetTable("TABLE_NAME");

    // Delete rows
    var filter = Builders<Row>.TableFilter.Eq(
      "title",
      "Hidden Shadows of the Past"
    );
    await table.DeleteManyAsync(filter);
  }
}
curl -sS -L -X POST "API_ENDPOINT/v1/KEYSPACE_NAME/TABLE_NAME" \
  --header "Token: APPLICATION_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "deleteMany": {
    "filter": {
      "title": "Hidden Shadows of the Past"
    }
  }
}'

Delete rows in a table with a composite primary key

If the table has a composite primary key, the filter must include all columns in the primary key definition (all partition keys), and it cannot include any other columns.

In the following example, the table has a composite primary key with the columns title and author.

For more information, see Primary keys in tables and Filter operators for tables.

  • Python

  • TypeScript

  • Java

  • C#

  • curl

from astrapy import DataAPIClient
from astrapy.authentication import UsernamePasswordTokenProvider
from astrapy.constants import Environment

# Get an existing table
client = DataAPIClient(environment=Environment.HCD)
database = client.get_database(
    "API_ENDPOINT",
    token=UsernamePasswordTokenProvider("USERNAME", "PASSWORD"),
)
table = database.get_table("TABLE_NAME", keyspace="KEYSPACE_NAME")

# Delete rows
table.delete_many(
    {"title": "Hidden Shadows of the Past", "author": "John Anthony"}
)
import {
  DataAPIClient,
  UsernamePasswordTokenProvider,
} from "@datastax/astra-db-ts";

// Get an existing table
const client = new DataAPIClient({ environment: "hcd" });
const database = client.db("API_ENDPOINT", {
  token: new UsernamePasswordTokenProvider("USERNAME", "PASSWORD"),
});
const table = database.table("TABLE_NAME", {
  keyspace: "KEYSPACE_NAME",
});

// Delete rows
(async function () {
  const result = await table.deleteMany({
    title: "Hidden Shadows of the Past",
    author: "John Anthony",
  });

  console.log(result);
})();
import com.datastax.astra.client.DataAPIClients;
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.core.query.Filters;
import com.datastax.astra.client.tables.Table;
import com.datastax.astra.client.tables.definition.rows.Row;

public class Example {

  public static void main(String[] args) {
    // Get an existing table
    Table<Row> table =
        DataAPIClients.clientHCD("USERNAME", "PASSWORD")
            .getDatabase("API_ENDPOINT", "KEYSPACE_NAME")
            .getTable("TABLE_NAME");

    // Delete rows
    Filter filter =
        Filters.and(
            Filters.eq("title", "Hidden Shadows of the Past"),
            Filters.eq("author", "John Anthony"));

    table.deleteMany(filter);
  }
}
using DataStax.AstraDB.DataApi;
using DataStax.AstraDB.DataApi.Core;
using DataStax.AstraDB.DataApi.Tables;

namespace Examples;

public class Program
{
  static async Task Main()
  {
    // Get an existing table
    var client = new DataAPIClient(
      new CommandOptions() { Destination = DataAPIDestination.HCD }
    );

    var database = client.GetDatabase(
      "API_ENDPOINT",
      DataAPIClient.UsernamePasswordTokenProvider(
        "USERNAME",
        "PASSWORD"
      ),
      "KEYSPACE_NAME"
    );

    var table = database.GetTable("TABLE_NAME");

    // Delete rows
    var filterBuilder = Builders<Row>.TableFilter;
    var filter = filterBuilder.And(
      filterBuilder.Eq("title", "Hidden Shadows of the Past"),
      filterBuilder.Eq("author", "John Anthony")
    );

    await table.DeleteManyAsync(filter);
  }
}
curl -sS -L -X POST "API_ENDPOINT/v1/KEYSPACE_NAME/TABLE_NAME" \
  --header "Token: APPLICATION_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "deleteMany": {
    "filter": {
      "title": "Hidden Shadows of the Past",
      "author": "John Anthony"
    }
  }
}'

Delete rows in a table with a compound primary key

If the table has a compound primary key, the filter must include all of the partition (grouping) columns in the primary key.

The filter can also include clustering (sorting) columns from the primary key:

  • The order of the clustering columns in the filter must match the order in the primary key definition. You can omit clustering keys, but you cannot skip any clustering keys. For example, if you have three clustering keys, a, b, and c, then you can include a and omit b and c. However, if you include b, then you must also include a.

  • The last clustering column can use range operators ($gt, $gte, $lt, and $lte) or the $eq operator. All other clustering columns can only use the $eq operator. For example, if your table has three clustering keys, a, b, and c, then you can only use range operators with c.

The filter cannot include any other columns.

In the following example, the table has a compound primary key with the partition column title and the clustering column rating.

For more information, see Primary keys in tables and Filter operators for tables.

  • Python

  • TypeScript

  • Java

  • C#

  • curl

from astrapy import DataAPIClient
from astrapy.authentication import UsernamePasswordTokenProvider
from astrapy.constants import Environment

# Get an existing table
client = DataAPIClient(environment=Environment.HCD)
database = client.get_database(
    "API_ENDPOINT",
    token=UsernamePasswordTokenProvider("USERNAME", "PASSWORD"),
)
table = database.get_table("TABLE_NAME", keyspace="KEYSPACE_NAME")

# Delete rows
table.delete_many({"title": "Hidden Shadows of the Past", "rating": 4})
import {
  DataAPIClient,
  UsernamePasswordTokenProvider,
} from "@datastax/astra-db-ts";

// Get an existing table
const client = new DataAPIClient({ environment: "hcd" });
const database = client.db("API_ENDPOINT", {
  token: new UsernamePasswordTokenProvider("USERNAME", "PASSWORD"),
});
const table = database.table("TABLE_NAME", {
  keyspace: "KEYSPACE_NAME",
});

// Delete rows
(async function () {
  const result = await table.deleteMany({
    title: "Hidden Shadows of the Past",
    rating: 4,
  });

  console.log(result);
})();
import com.datastax.astra.client.DataAPIClients;
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.core.query.Filters;
import com.datastax.astra.client.tables.Table;
import com.datastax.astra.client.tables.definition.rows.Row;

public class Example {

  public static void main(String[] args) {
    // Get an existing table
    Table<Row> table =
        DataAPIClients.clientHCD("USERNAME", "PASSWORD")
            .getDatabase("API_ENDPOINT", "KEYSPACE_NAME")
            .getTable("TABLE_NAME");

    // Delete rows
    Filter filter =
        Filters.and(Filters.eq("title", "Hidden Shadows of the Past"), Filters.eq("rating", 4));

    table.deleteMany(filter);
  }
}
using DataStax.AstraDB.DataApi;
using DataStax.AstraDB.DataApi.Core;
using DataStax.AstraDB.DataApi.Tables;

namespace Examples;

public class Program
{
  static async Task Main()
  {
    // Get an existing table
    var client = new DataAPIClient(
      new CommandOptions() { Destination = DataAPIDestination.HCD }
    );

    var database = client.GetDatabase(
      "API_ENDPOINT",
      DataAPIClient.UsernamePasswordTokenProvider(
        "USERNAME",
        "PASSWORD"
      ),
      "KEYSPACE_NAME"
    );

    var table = database.GetTable("TABLE_NAME");

    // Delete rows
    var filterBuilder = Builders<Row>.TableFilter;
    var filter = filterBuilder.And(
      filterBuilder.Eq("title", "Hidden Shadows of the Past"),
      filterBuilder.Eq("rating", 4)
    );

    await table.DeleteManyAsync(filter);
  }
}
curl -sS -L -X POST "API_ENDPOINT/v1/KEYSPACE_NAME/TABLE_NAME" \
  --header "Token: APPLICATION_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "deleteMany": {
    "filter": {
      "title": "Hidden Shadows of the Past",
      "rating": 4
    }
  }
}'

Delete all rows

To delete all rows, use an empty filter.

  • Python

  • TypeScript

  • Java

  • C#

  • curl

from astrapy import DataAPIClient
from astrapy.authentication import UsernamePasswordTokenProvider
from astrapy.constants import Environment

# Get an existing table
client = DataAPIClient(environment=Environment.HCD)
database = client.get_database(
    "API_ENDPOINT",
    token=UsernamePasswordTokenProvider("USERNAME", "PASSWORD"),
)
table = database.get_table("TABLE_NAME", keyspace="KEYSPACE_NAME")

# Delete rows
table.delete_many({})
import {
  DataAPIClient,
  UsernamePasswordTokenProvider,
} from "@datastax/astra-db-ts";

// Get an existing table
const client = new DataAPIClient({ environment: "hcd" });
const database = client.db("API_ENDPOINT", {
  token: new UsernamePasswordTokenProvider("USERNAME", "PASSWORD"),
});
const table = database.table("TABLE_NAME", {
  keyspace: "KEYSPACE_NAME",
});

// Delete rows
(async function () {
  const result = await table.deleteMany({});

  console.log(result);
})();
import com.datastax.astra.client.DataAPIClients;
import com.datastax.astra.client.core.query.Filter;
import com.datastax.astra.client.tables.Table;
import com.datastax.astra.client.tables.definition.rows.Row;

public class Example {

  public static void main(String[] args) {
    // Get an existing table
    Table<Row> table =
        DataAPIClients.clientHCD("USERNAME", "PASSWORD")
            .getDatabase("API_ENDPOINT", "KEYSPACE_NAME")
            .getTable("TABLE_NAME");

    // Delete rows
    table.deleteMany(new Filter());
  }
}
using DataStax.AstraDB.DataApi;
using DataStax.AstraDB.DataApi.Core;
using DataStax.AstraDB.DataApi.Tables;

namespace Examples;

public class Program
{
  static async Task Main()
  {
    // Get an existing table
    var client = new DataAPIClient(
      new CommandOptions() { Destination = DataAPIDestination.HCD }
    );

    var database = client.GetDatabase(
      "API_ENDPOINT",
      DataAPIClient.UsernamePasswordTokenProvider(
        "USERNAME",
        "PASSWORD"
      ),
      "KEYSPACE_NAME"
    );

    var table = database.GetTable("TABLE_NAME");

    // Delete rows
    await table.DeleteManyAsync(Builders<Row>.TableFilter.Empty());
  }
}
curl -sS -L -X POST "API_ENDPOINT/v1/KEYSPACE_NAME/TABLE_NAME" \
  --header "Token: APPLICATION_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "deleteMany": {
    "filter": {}
  }
}'

Similarly, an empty deleteMany object deletes all rows.

curl -sS -L -X POST "API_ENDPOINT/v1/KEYSPACE_NAME/TABLE_NAME" \
  --header "Token: APPLICATION_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "deleteMany": {}
}'

Client reference

  • Python

  • TypeScript

  • Java

  • C#

  • curl

For more information, see the client reference.

For more information, see the client reference.

For more information, see the client reference.

For more information, see the client reference.

Client reference documentation is not applicable for HTTP.

Was this helpful?

Give Feedback

How can we improve the documentation?

© Copyright IBM Corporation 2026 | Privacy policy | Terms of use Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: Contact IBM