功能介绍
truncate_collection() 用于清空 Collection 中所有的数据与索引,仅保留 Collection 配置信息,例如索引类型及参数、分片等设置,减少用户的操作成本。
接口约束
警告:
执行 truncate 操作将会永久删除指定 Collection 下的所有数据。在操作之前,务必谨慎考虑。
请求示例
import tcvectordbfrom tcvectordb.model.enum import ReadConsistency#create a database client objectclient = tcvectordb.RPCVectorDBClient(url='http://10.0.X.X:80', username='root', key='eC4bLRy2va******************************
', read_consistency=ReadConsistency.EVENTUAL_CONSISTENCY, timeout=30)# Specify the database namedb = client.database('db_test')db.truncate_collection(collection_name='book-emb')
输出信息,如下所示。
{"affectedCount": 1}
请求参数
参数 | 是否必选 | 参数含义 | 配置方法及要求 |
collection_name | 是 | 指定需清空数据的 Collection 名。 |
返回参数
参数名 | 参数含义 |
affectedCount | 影响行数,即为清空的集合数量。 |