2012-07-24 78 views
5

我的數據庫中有大約300個表。我想要包含列名sname,dtcreatedat,dtmodifiedat,ixlastmodifiedby和fstatus的表名。目前我正在手動檢查每個表格。可以在mysql中使用哪個命令來做到這一點?選擇包含特定列的所有表

回答

6

您可以找到包含與列的所有表:

select distinct table_name 
from information_schema.columns 
where column_name in ('sname','dtcreatedat','dtmodifiedat','ixlastmodifiedby','fstatus') 
and table_schema = 'your_db_name' 
+0

這將從所有數據庫檢索表。如果我想從特定的數據庫中檢索表格呢? – 2012-07-24 10:04:44

+1

然後添加'和table_schema ='db_name''。我更新了答案。 – 2012-07-24 10:08:47