mysql/mariadb information_schema 查看创建时间

mysql/mariadb information_schema view creation time

我想查找在特定时间戳之前创建的所有 table 和视图。对于 tables 这很简单,只需

SELECT * FROM information_schema.tables
WHERE table_type = 'TABLE' AND create_time < :ts

但是对于视图来说就没那么简单了。对于 information_chema.tables 中的所有视图,create_time 列为空。例如

MariaDB [MYDB]> SELECT IF(create_time IS NULL, 'Null', 'Not Null') AS has_create_ts
                     , COUNT(1)
FROM information_schema.tables
WHERE table_type = 'VIEW' GROUP BY has_create_ts;
+---------------+----------+
| has_create_ts | COUNT(1) |
+---------------+----------+
| Null          |       70 |
+---------------+----------+
1 row in set, 10 warnings (0.371 sec)

并且 information_schema.views table 没有任何时间戳列。

那么我怎样才能知道视图的创建时间呢?还是根本不可能。

如果重要的数据库版本是:

MariaDB [MYDB]> SELECT VERSION();
+--------------------+
| VERSION()          |
+--------------------+
| 10.3.7-MariaDB-log |
+--------------------+
1 row in set (0.392 sec)

So how can I find out when a view was created? Or is it just not possible.

不,这是不可能的。

视图实际上并不包含数据,它只是由一个定义构成,即 SQL 引用包含在 真实 (物理)表中的数据的语句:因此这就是 INFORMATION_SCHEMA.VIEWS 可以向您展示的所有内容。