在 MYSQL 中创建一个列出所有数据库的 table?
Creating a table in MYSQL that lists all databases?
我一直在互联网上搜索,试图找到这个问题的答案,但没有成功。
基本上我有几个包含多个 table 的数据库,我想为其创建一个 table。
我想一个视图可能会更好,但无论如何,我想创建一个 php 脚本来调用 said view/table 列出我所有的数据库(我知道有一个显示所有数据库命令,但我认为我无法在 phpmyadmin),
之外显示它
我还希望它能够在新数据库添加到服务器时进行自我更新,这就是为什么我认为视图可能是必要的。我不确定这是否可能导致我来到这里。任何关于此事的线索将不胜感激!
谢谢
我会使用 show databases command, not a table. Basically you're using the table of MySQL itself with that command. It will also automatically update! Here's the PDO variant.
我会用这个:
SELECT * FROM INFORMATION_SCHEMA.SCHEMATA
阅读更多:https://dev.mysql.com/doc/refman/8.0/en/information-schema-schemata-table.html
我一直在互联网上搜索,试图找到这个问题的答案,但没有成功。
基本上我有几个包含多个 table 的数据库,我想为其创建一个 table。
我想一个视图可能会更好,但无论如何,我想创建一个 php 脚本来调用 said view/table 列出我所有的数据库(我知道有一个显示所有数据库命令,但我认为我无法在 phpmyadmin),
之外显示它我还希望它能够在新数据库添加到服务器时进行自我更新,这就是为什么我认为视图可能是必要的。我不确定这是否可能导致我来到这里。任何关于此事的线索将不胜感激!
谢谢
我会使用 show databases command, not a table. Basically you're using the table of MySQL itself with that command. It will also automatically update! Here's the PDO variant.
我会用这个:
SELECT * FROM INFORMATION_SCHEMA.SCHEMATA
阅读更多:https://dev.mysql.com/doc/refman/8.0/en/information-schema-schemata-table.html