問題描述
我想在 MySQL 數(shù)據(jù)庫的所有表的所有字段中搜索給定字符串,可能使用以下語法:
I want to search in all fields from all tables of a MySQL database a given string, possibly using syntax as:
SELECT * FROM * WHERE * LIKE '%stuff%'
有沒有可能做這樣的事情?
Is it possible to do something like this?
推薦答案
您可以查看 information_schema
架構(gòu).它具有所有表和表中所有字段的列表.然后,您可以使用從該表中獲得的信息運行查詢.
You can peek into the information_schema
schema. It has a list of all tables and all fields that are in a table. You can then run queries using the information that you have gotten from this table.
涉及的表是SCHEMATA、TABLES和COLUMNS.有外鍵,您可以準(zhǔn)確地構(gòu)建在模式中創(chuàng)建表的方式.
The tables involved are SCHEMATA, TABLES and COLUMNS. There are foreign keys such that you can build up exactly how the tables are created in a schema.
這篇關(guān)于在 MySQL 數(shù)據(jù)庫的每個表的字段中搜索文本的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!