接口定义
truncateCollections() 用于清空 Base 类数据库的 Collection 中所有的数据与索引,仅保留 Collection 配置信息,例如索引类型及参数、分片等设置,减少用户的操作成本。
AffectRes truncateCollections(String databaseName, String collectionName)
接口约束
警告:
执行 truncate 操作将会永久删除指定 Collection 下的所有数据。在操作之前,务必谨慎考虑。
使用示例
private static final String DBNAME = "db-test";private static final String COLL_NAME = "book-vector";// truncateAffectRes affectRes = client.truncateCollections(DBNAME, COLL_NAME);System.out.println("\\tres: " + affectRes);
入参描述
参数名 | 是否必选 | 参数含义 | 配置方法 |
databaseName | 是 | 查询的集合所在的数据库名 | 只能使用英文字母,数字,下划线_、中划线-,并以英文字母开头。 长度要求:[1,128]。 |
collectionName | 是 | 查询的 Collection 名称。 | 只能使用英文字母,数字,下划线_、中划线-,并以英文字母开头。 长度要求:[1,128]。 |
出参描述
res: AffectRes{affectedCount=1, code=0, msg='operation success'}
参数名 | 参数含义 |
affectedCount | 影响行数,即为清空数据的集合数量。 |