我需要创建这样的视图
create view GetProcessList as show processlist
有可能吗?
sqxo8psd1#
有可能吗?否,您只能基于SELECT语句创建视图,而不能基于SHOW语句创建。但是,如果您的问题真的是如何像访问一个表一样访问进程列表……那么在INFORMATION_SCHEMA元数据库中就已经有了:
MariaDB [information_schema]> SELECT * FROM information_schema.PROCESSLIST; +----+------+-----------+--------------------+---------+------+----------------------+----------------------------------------------+---------+-------+-----------+----------+-------------+---------------+----------+ | ID | USER | HOST | DB | COMMAND | TIME | STATE | INFO | TIME_MS | STAGE | MAX_STAGE | PROGRESS | MEMORY_USED | EXAMINED_ROWS | QUERY_ID | +----+------+-----------+--------------------+---------+------+----------------------+----------------------------------------------+---------+-------+-----------+----------+-------------+---------------+----------+ | 42 | root | localhost | information_schema | Query | 0 | Filling schema table | SELECT * FROM information_schema.PROCESSLIST | 0.561 | 0 | 0 | 0.000 | 83104 | 0 | 204 | +----+------+-----------+--------------------+---------+------+----------------------+----------------------------------------------+---------+-------+-----------+----------+-------------+---------------+----------+ 1 row in set (0.00 sec)
1条答案
按热度按时间sqxo8psd1#
有可能吗?
否,您只能基于SELECT语句创建视图,而不能基于SHOW语句创建。但是,如果您的问题真的是如何像访问一个表一样访问进程列表……那么在INFORMATION_SCHEMA元数据库中就已经有了: