MySQL:不使用任何 "show tables from database_name"或 "select table_name from information_schema.tables"查询返回表名

标签 mysql sql database

我试图在不使用“show tables from database_name”或“select table_name from information_schema.tables”查询的情况下返回表名,原因是:

  1. 我不能使用“show tables from database_name”查询,因为它返回一组具有固定字段名称“Tables_database_name”的表名称行,当数据库名称太长时,这在我的代码中是 Not Acceptable - 我在 Delphi 上使用 DBExpress,列名不能超过 31 个字符-。

  2. 我不能使用“select table_name from information_schema.tables”查询,因为它不支持我认为早于 5.1 的旧 MySQL

如果有人知道请帮忙:

  • 如何更改“show tables from database_name”的结果固定列名称。

  • 返回特定数据库中的表名的任何其他查询。

最佳答案

How to change the resulted fixed column name of the "show tables from database_name".

似乎 SHOW TABLES 是一个具有固定语法的单独语句:

SHOW [FULL] TABLES [{FROM | IN} db_name] [LIKE 'pattern' | WHERE expr]

http://dev.mysql.com/doc/refman/5.0/en/show-tables.html

它不是 SELECT,因此您不能与它联合或以任何形式(更改列名)使用它,所以我想这个问题的答案是:这是不可能的。

Any other query that returns the table names inside a specific database.

如果你比较这个: http://dev.mysql.com/doc/refman/4.1/en/show-tables.html

对此: http://dev.mysql.com/doc/refman/5.0/en/show-tables.html

似乎在 5.0 之前唯一可以替代 SHOW TABLES 的是“mysqlshow”shell 命令

information_schema是MySql 5.0引入的,8年前就稳定了。所以我猜您正在尝试使您的软件与非常旧的版本兼容。


当列名超过 31 个字符时,这个“DBExpress”会做什么?它会截断它还是失败?也许您应该提出一个标记为“delphi”和“DBExpress”的问题,并询问如何绕过此限制?

关于MySQL:不使用任何 "show tables from database_name"或 "select table_name from information_schema.tables"查询返回表名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16518412/

相关文章:

android - 关于ionic框架和从服务器获取数据

php - 使用 add_months 时在 oracle 中不是有效月份

mysql - MySQL 中何时使用单引号、双引号和反引号

SQL 减去整整一年

database - Docker Swarm 如何处理数据库(PostgreSQL)复制?

mysql - SET运算符在mysql中的使用。解释?

php - 检查数据库凭据是否有效?

mysql - 创建表Mysql集群问题

php - 使用 ASIHTTP 从 iPhone 应用程序发送日期到 php 应用程序

java - 哪种数据库和编码方案适合音频数据存储?