显示表 FULLTEXT 索引列
我希望运行一个查询,该查询将返回表中全文索引的列列表。该表采用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以从 information_schema.STATISTICS 表中获取该信息。
我将向您提供查询以获取表中位于一个或多个 FULLTEXT 索引中的所有列,因为我认为这就是您所要求的。请记住,每个 FULLTEXT 索引中的特定列组合非常重要。 MySQL 无法使用 FULLTEXT 索引来搜索多个列,除非有一个 FULLTEXT 索引包含所有这些列。
这是给出您要求的输出的第一个查询:
如果表上有超过 1 个列,则显示 FULLTEXT 索引中列的各种组合:
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:
And here's one that shows the various combinations of columns in FULLTEXT indexe if there is more than 1 on the table:
这是另一种方法:
将括号中的占位符替换为您自己的值。
仔细阅读 FULLTEXT 行的输出。
Here's another way:
Replace the bracketed placeholders with your own values.
Peruse the output for FULLTEXT lines.
我来得太晚了,但它就在这里。
如果您不记得已索引的表名称,您可以从
information_schema
数据库获取它们的表和架构名称。您需要做的就是 -
上面的代码只会为您提供包含全文索引的所有表的名称。
但是,这将为您提供数据库名称以及具有全文索引的表名称
希望这有帮助!
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 -
The above code will give you only the names of all tables which contains full-text indexing.
However, this will give you database name as well as the table name which have full text indexing
Hope this helps!
我只是要放弃对我有用的东西。
确保 db_name 和 table_name 位于单独的反引号中,并通过点 (.) 连接在一起。
I'm just going to drop what worked for me.
Ensure that the db_name and table_name are in separate backticks joined together by a dot(.).