【发布时间】:2019-06-25 13:13:56
【问题描述】:
我想查找在某个时间戳之前创建的所有表和视图。对于表格,这很简单,只需
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 表没有任何时间戳列。
那么我怎样才能知道视图是什么时候创建的呢?还是根本不可能。
如果重要,数据库版本是:
MariaDB [MYDB]> SELECT VERSION();
+--------------------+
| VERSION() |
+--------------------+
| 10.3.7-MariaDB-log |
+--------------------+
1 row in set (0.392 sec)
【问题讨论】:
-
向 MySQL 和/或 MariaDB 提交“功能请求”。
标签: mysql sql mariadb information-schema