SQLite创建预填充的FTS表 [英] SQLite create pre-populated FTS table
问题描述
有没有一种方法可以在SQLite中创建一个FTS表,该表中已预先填充了SELECT查询中的数据?
Is there a way to create an FTS table in SQLite that is pre-populated with data from a SELECT query?
我知道可以创建一个常规表其中预填充了SELECT数据:
创建表foo AS SELECT ref_id,名称FROM other_table
I know it’s possible to create a regular table that is prepopulated with data from a SELECT:
CREATE TABLE foo AS SELECT ref_id, name FROM other_table
然后我们可以像这样创建FTS表:
使用FTS3(ref_id,name)创建虚拟表栏
And we can create an FTS table like so:
CREATE VIRTUAL TABLE bar USING FTS3(ref_id, name)
这样做的目的是更新我的应用程序的SQLite数据库架构,同时避免从 other_table
中读取所有数据。我真的希望有一种方法可以让SQLite在这里完成所有繁重的工作(这是它真正擅长的事情!)。
The point of doing this is to update my app’s SQLite database schema while avoiding reading in all of the data from other_table
. I’m really hoping there’s some way to let SQLite do all the heavy lifting here (which is what it's really good at!).
推荐答案
我不确定是否可以在一个语句中执行此操作,但是可以在两个语句中执行...在您创建 CREATE VIRTUAL TABLE
语句后,您可以执行:插入到栏SELECT * FROM other_table
I'm not sure if you can do it in one statement, but you can do it in two... after your CREATE VIRTUAL TABLE
statement, you can do: INSERT INTO bar SELECT * FROM other_table
这篇关于SQLite创建预填充的FTS表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!