Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 在Vertica的数据库中全局创建反向索引_Sql_Database_Indexing_Vertica_Inverted Index - Fatal编程技术网

Sql 在Vertica的数据库中全局创建反向索引

Sql 在Vertica的数据库中全局创建反向索引,sql,database,indexing,vertica,inverted-index,Sql,Database,Indexing,Vertica,Inverted Index,我想快速识别Vertica中存储的数据库中包含某个关键字的表和列。Vertica提供全文搜索功能。但是,只能为某个模式/关系构建文本索引,而不能为整个数据库构建文本索引 有人知道在Vertica中是否有一种简单的方法可以为整个数据库建立反向索引吗?您无法创建跨越多个对象的单个文本索引。每个索引都是表中单个列的索引 您也许可以通过在列表中查找列来生成所需的创建(尽管诚实地创建这些列并不常见)。这假设每个表都有一个名为id的主键。我只是想简化一下 select 'create text index

我想快速识别Vertica中存储的数据库中包含某个关键字的表和列。Vertica提供全文搜索功能。但是,只能为某个模式/关系构建文本索引,而不能为整个数据库构建文本索引


有人知道在Vertica中是否有一种简单的方法可以为整个数据库建立反向索引吗?

您无法创建跨越多个对象的单个文本索引。每个索引都是表中单个列的索引

您也许可以通过在列表中查找列来生成所需的创建(尽管诚实地创建这些列并不常见)。这假设每个表都有一个名为
id
的主键。我只是想简化一下

select 'create text index ' || table_schema || '.t_' || table_name || '_' || column_name 
                            || '_index on ' || table_schema || '.' || table_name 
                            || '(id,' || column_name || ');'
from columns 
where data_type ilike '%char';
然后,您可以创建一个从所有文本索引中进行选择的视图。不过,作为记录,我不知道这会有多好。有人会认为优化器会做它需要做的事情,但很难说确定。这可以类似于上面的查询生成,完成后看起来是这样的(注意,如果您是分区,则需要为此添加一列)


不过,我不知道这对你来说会有多好。YMMV.

如果我误解了这个问题,请告诉我。你非常理解我的问题。谢谢事实上,我提出了一个类似的解决方案。如果出现性能问题,我会通知您。只需确保执行
union all
,而不是
union
。你可能知道,但我想我会叫出来以防万一。
create view v_all_text_indexes
as
select 'schema1' schema_name, 'table1' table_name, 'column1' column_name, word, doc_id
from schema1.t_table1_column1_index
union all
select 'schema1' schema_name, 'table1' table_name, 'column2' column_name, word, doc_id
from schema1.t_table1_column2_index
.
.
.
select 'schema1' schema_name, 'tablen' table_name, 'columnn' column_name, word, doc_id
from schema1.t_tablen_columnn_index