从具有特定列的MySQL数据库获取所有表,比方说xyz?
假设我们有一个数据库“web”,我们需要获取所有具有特定列“StudentFirstName”的表。
为此,下面是查询-
mysql> select myColumnName.table_name from information_schema.columns myColumnName where myColumnName.column_name = 'StudentFirstName' and table_schema='web';
这将产生以下输出-
+---------------+ | TABLE_NAME | +---------------+ | demotable109 | | demotable297 | | demotable335 | | demotable395 | | demotable418 | | demotable425 | | demotable436 | +---------------+ 7 rows in set (0.14 sec)
因此,以上表格的列名称之一为“StudentFirstName”。
让我们检查任何表的描述以查找列名“StudentFirstName”-
mysql> desc demotable297;
这将产生以下输出,其中显示列名称之一为“StudentFirstName”-
+------------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------+--------------+------+-----+---------+-------+ | StudentId | int(11) | YES | | NULL | | | StudentFirstName | varchar(100) | YES | | NULL | | | StudentLastName | varchar(100) | YES | | NULL | | +------------------+--------------+------+-----+---------+-------+ 3 rows in set (0.01 sec)
热门推荐
10 毕业写给学校简短祝福语
11 老总儿子生日祝福语简短
12 立春幽默祝福语简短
13 送米的祝福语简短
14 天仓节祝福语简短
15 开张祝福语简短小故事
16 年末祝福语简短小清新
17 鼠年元旦生日祝福语简短
18 婚庆开业祝福语大全简短