如何创建多列索引DuckDB/SQLite?

How to create multi-column indices DuckDB/SQLite?

我有一个包含数据列的 DuckDB,我想使用多列进行查询。我在 R 中,但我不确定如何创建多列索引(甚至是单列索引)。有人可以建议参考吗?我已将 SQLite 添加为标记,因为我收集到这些命令可能相同。

编辑: 根据 kukuk1de 的建议,我正在尝试以下

require(DBI)
require(duckdb)

DBI::dbExecute(con,statement = "CREATE INDEX multi_idx ON  (percent prevalence fresh_flow maskProp dropExhale)")

但我收到以下错误:

Error in .local(conn, statement, ...) : 
  duckdb_prepare_R: Failed to prepare query CREATE INDEX multi_idx ON  (percent prevalence fresh_flow maskProp dropExhale)
Error: Parser Error: syntax error at or near "("
LINE 1: CREATE INDEX multi_idx ON  (percent prevalence fresh_flow maskProp...

试试这个:

library("DBI")

con = dbConnect(duckdb::duckdb(), dbdir=":memory:", read_only=FALSE)

dbExecute(con, "CREATE TABLE items(item VARCHAR, value DECIMAL(10,2), count INTEGER)")
dbExecute(con, "INSERT INTO items VALUES ('jeans', 20.0, 1), ('hammer', 42.2, 2)")

dbExecute(con, "CREATE INDEX itemcount_idx ON items (item, count);")

运行最后一条命令再次告诉你索引已经存在。

dbExecute(con, "CREATE INDEX itemcount_idx ON items (item, count);")
Error in duckdb_execute(res) : duckdb_execute_R: Failed to run query
Error: Catalog Error: Index with name "itemcount_idx" already exists!