如何获取 MySQL 视图列表?
2021-11-20 00:00:00
mysql
我正在寻找一种方法来列出数据库中的所有视图.
I'm looking for a way to list all views in a database.
最初我在 MySQL 论坛上找到并尝试了 答案:
Initially I found and tried an answer on the MySQL forums:
SELECT table_name
FROM information_schema.views
WHERE information_schema.views.table_schema LIKE 'view%';
无论如何这都不起作用,返回一个空集.(我知道他们在那里!)
How ever this doesn't work, returning an empty set. (I know they're in there!)
这些也失败了:
mysql> use information_schema;
Database changed
mysql> select * from views;
ERROR 1102 (42000): Incorrect database name 'mysql.bak'
mysql> select * from tables;
ERROR 1102 (42000): Incorrect database name 'mysql.bak'
为什么这不起作用?
推荐答案
SHOW FULL TABLES IN database_name WHERE TABLE_TYPE LIKE 'VIEW';
MySQL 查询以查找数据库中的所有视图
相关文章