Database 文件室预打包数据库中的索引不工作
我在预先打包的数据库中有一个表,我使用此查询创建了该表的索引Database 文件室预打包数据库中的索引不工作,database,sqlite,android-studio,indexing,android-room,Database,Sqlite,Android Studio,Indexing,Android Room,我在预先打包的数据库中有一个表,我使用此查询创建了该表的索引 CREATE INDEX index_less_equal_to_L ON entries_less_equal_to_L(entry_word); 我在我的房间里用这个 @Entity(tableName = "entries_less_equal_to_L", indices = {@Index("index_less_ equal_to_L"), @Index(value = "
CREATE INDEX index_less_equal_to_L ON entries_less_equal_to_L(entry_word);
我在我的房间里用这个
@Entity(tableName = "entries_less_equal_to_L", indices = {@Index("index_less_ equal_to_L"), @Index(value = "entry_word")})
但它不起作用,让我看看这个
[生成错误输出]:
我做错了什么?您试图创建两个索引,每个@Index对应一个 第一个将命名为index_less_uequal_to_L,但没有列,因此出现错误消息 第二个将使用生成的名称成功创建,并位于entry_word列上。索引的名称应符合以下要求:- 如果未设置,则文件室会将其设置为索引${tableName}连接并以其为前缀的列列表。因此,如果您有一个名为Foo的表,并且索引为{bar,baz},那么生成的索引名将是index_Foo_bar_baz 因此,您需要将这两者合并为一个索引 您可以使用u和等于_to L之间的空格,因为我假设这是一个键入错误
indices = {@Index(name = "index_less_equal_to_L",value = "entry_word")}
或
后者更灵活,因为它允许复合标记多个列。这正是我需要的,谢谢!
indices = {Index(name ="index_less_equal_to_L",value = {"entry_word"})}