显示表 FULLTEXT 索引列

发布于 2024-09-30 18:48:14 字数 159 浏览 4 评论 0原文

我希望运行一个查询,该查询将返回表中全文索引的列列表。该表采用 MyISAM 格式,我将使用 php 来构建查询。

理想情况下,我会运行查询,它会返回信息,以便我可以构造一个以逗号分隔的列字符串。

例如“名字、姓氏、电子邮件”

这在 MySQL 中可能吗?

I'm looking to run a query that will return a list of columns in a table that are FULLTEXT indexed. The table is in MyISAM format and i'll be using php to construct the query.

Ideally i would run the query and it would return the information so i could construct a comma separated string of the columns.

e.g. "first_name, last_name, email"

Is this possible in MySQL?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

那支青花 2024-10-07 18:48:14

您可以从 information_schema.STATISTICS 表中获取该信息。

我将向您提供查询以获取表中位于一个或多个 FULLTEXT 索引中的所有列,因为我认为这就是您所要求的。请记住,每个 FULLTEXT 索引中的特定列组合非常重要。 MySQL 无法使用 FULLTEXT 索引来搜索多个列,除非有一个 FULLTEXT 索引包含所有这些列。

这是给出您要求的输出的第一个查询:

select group_concat(distinct column_name)
from information_schema.STATISTICS 
where table_schema = 'your_db' 
and table_name = 'your_table' 
and index_type = 'FULLTEXT';

如果表上有超过 1 个列,则显示 FULLTEXT 索引中列的各种组合:

select index_name, group_concat(column_name) as columns
from information_Schema.STATISTICS 
where table_schema = 'your_db' 
and table_name = 'your_table' 
and index_type = 'FULLTEXT'
group by index_name;

You can get that information from the information_schema.STATISTICS table.

I'll give you the query to get all columns in the table that are in one or more FULLTEXT indexes, since I think that's what you are asking for. Bear in mind that the specific combinations of columns in each FULLTEXT index are very important. MySQL can't use a FULLTEXT index to search multiple columns unless there is a single FULLTEXT index that includes all of those column.

Here's the first query that gives the output you asked for:

select group_concat(distinct column_name)
from information_schema.STATISTICS 
where table_schema = 'your_db' 
and table_name = 'your_table' 
and index_type = 'FULLTEXT';

And here's one that shows the various combinations of columns in FULLTEXT indexe if there is more than 1 on the table:

select index_name, group_concat(column_name) as columns
from information_Schema.STATISTICS 
where table_schema = 'your_db' 
and table_name = 'your_table' 
and index_type = 'FULLTEXT'
group by index_name;
庆幸我还是我 2024-10-07 18:48:14

这是另一种方法:

SHOW CREATE TABLE [database_name].[table_name]

将括号中的占位符替换为您自己的值。

仔细阅读 FULLTEXT 行的输出。

Here's another way:

SHOW CREATE TABLE [database_name].[table_name]

Replace the bracketed placeholders with your own values.

Peruse the output for FULLTEXT lines.

清醇 2024-10-07 18:48:14

我来得太晚了,但它就在这里。

如果您不记得已索引的表名称,您可以从 information_schema 数据库获取它们的表和架构名称。

您需要做的就是 -

select table_name from information_schema.STATISTICS  where table_schema = 'your_schema_name'  and index_type = 'FULLTEXT';

上面的代码只会为您提供包含全文索引的所有表的名称。

select table_name,table_schema from information_schema.STATISTICS  where index_type = 'FULLTEXT';

但是,这将为您提供数据库名称以及具有全文索引的表名称

希望这有帮助!

I am too late but here it is.

In case you don't remember the table names which you've indexed to, you can get their table and schema names from the information_schema database.

All you need to do is -

select table_name from information_schema.STATISTICS  where table_schema = 'your_schema_name'  and index_type = 'FULLTEXT';

The above code will give you only the names of all tables which contains full-text indexing.

select table_name,table_schema from information_schema.STATISTICS  where index_type = 'FULLTEXT';

However, this will give you database name as well as the table name which have full text indexing

Hope this helps!

单身情人 2024-10-07 18:48:14

我只是要放弃对我有用的东西。

SHOW CREATE TABLE `db_name`.`table_name`;

确保 db_name 和 table_name 位于单独的反引号中,并通过点 (.) 连接在一起。

I'm just going to drop what worked for me.

SHOW CREATE TABLE `db_name`.`table_name`;

Ensure that the db_name and table_name are in separate backticks joined together by a dot(.).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文