
要使用 SELECT 语句获取表名称,请使用“information_schema.tables”。让我们看一个例子,其中我们有一个包含 3 个表的数据库。借助 SELECT 语句获取所有表名称的语法。
SELECT Table_name as TablesName from information_schema.tables where table_schema = 'yourDatabaseName';
使用数据库“test”,并应用上述语法使用 SELECT 获取表名
本文介绍了Python操作MYSQL、执行SQL语句、获取结果集、遍历结果集、取得某个字段、获取表字段名、将图片插入数据库、执行事务等各种代码实例和详细介绍,代码居多,是一桌丰盛唯美的代码大餐。如果想查看在线版请访问:https://www.jb51.net/article/34102.htm
mysql> use test; Database changed mysql> SELECT Table_name as TablesName from information_schema.tables where table_schema = 'test';
输出三个表的名称。
+--------------------+ | TablesName | +--------------------+ | destination | | myisamtoinnodbdemo | | originaltable | +--------------------+ 3 rows in set (0.00 sec)









