要使用 SELECT 语句获取表名称,请使用“information_schema.tables”。让我们看一个例子,其中我们有一个包含 3 个表的数据库。借助 SELECT 语句获取所有表名称的语法。
SELECT Table_name as TablesName from information_schema.tables where table_schema = 'yourDatabaseName';
使用数据库“test”,并应用上述语法使用 SELECT 获取表名
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)
以上就是在 MySQL 中使用 SELECT 语句获取表名?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号