gpt4 book ai didi

MYSQL 选择以 "x"开头的表

转载 作者:行者123 更新时间:2023-11-29 11:40:32 25 4
gpt4 key购买 nike

我的“统计”数据库中有一堆表。

tcl20151w1d1
tcl20151w1d2
tcl20151w2d1
tcl20151w2d2
tcl20151w3d1
tcl20151w3d2
tcl20151w4d1
eu20151w1d1
eu20151w1d2
eu20151w2d1
eu20151w2d2
eu20151w3d1
eu20151w3d2
eu20151w4d1
..

如何选择“stats”数据库中以“tcl”开头的所有表。是否可以?我必须手动合并它们吗?

最佳答案

您可以查询information_schema.tables table 获取表名以 tcl 开头的表的列表。

您可以使用该列表在存储过程中使用字符串连接和 prepared statements 动态创建联合查询。 .

如果这些表都是相同结构的myisam表,你可以考虑创建一个merge table关于他们:

The MERGE storage engine, also known as the MRG_MyISAM engine, is a collection of identical MyISAM tables that can be used as one. “Identical” means that all tables have identical column and index information.

关于MYSQL 选择以 "x"开头的表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35849318/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com