Delete Vectors

Use the delete vectors operation to delete vectors from a table by their IDs.

The operation removes the specified vectors and their associated metadata from the table, essentially deleting the rows from the table for the given IDs.

An error is raised if the specified table does not exist.

See the following for an example of using delete_vectors:

from oracle_vecdb import OracleVecDB, Configuration

client = OracleVecDB(Configuration(
    rest_url="https://<host>/ords/<schema>/_/db-api/stable/vecdb/",
    access_token="<bearer-token>", # or username="<user>", password="<pass>"
))

#delete specific vectors
response = client.delete_vectors(
    table_name='products',
    ids=['prod_old_1', 'prod_old_2', 'prod_old_3']
)

print(response)

A JSON response is returned confirming successful deletion with a count of deleted vectors.

Example response:

{
    "message": "Deleted 3 vector records"
}

See how POST /vecdb/vector-tables/{vector_table_name}/delete can be used in the following example:

curl -X POST \
  "https://<host>:<port>/ords/<schema>/_/db-api/stable/vecdb/vector-tables/myvectors/delete" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  # Choose ONE authentication method:

  # Option 1: Basic authentication
  -u "<user>:<password>" \

  # Option 2: OAuth Bearer token
  # -H "Authorization: Bearer <access_token>" \

  -d '{
    "ids": ["vec1", "vec2"]
  }'

Responses:

  • Example 200 response:
    {
      "message": "Deleted 2 rows successfully"
    }
  • 400- the request body included invalid parameters.
  • 404 - the specified vector table does not exist.

For more information, see REST API Reference.

See how DBMS_VECTOR_DATABASE.DELETE_VECTORS can be used in the following example:

dbms_vector_database.delete_vectors(
    'myvectors', 
    JSON('["vec1", "vec2"]')
);

Example output:

{
  "message": "Deleted 2 rows successfully"
}

For more information about the PL/SQL implementation, including parameters, see DELETE_VECTORS.