gpt4 book ai didi

mysql/mariadb information_schema View 创建时间

转载 作者:行者123 更新时间:2023-11-29 09:52:57 27 4
gpt4 key购买 nike

我想查找在某个时间戳之前创建的所有表和 View 。对于表来说很简单,只需

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

但对于 View 来说,事情就没那么简单了。对于 information_chema.tables 中的所有 View ,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 表没有任何时间戳列。

那么我怎样才能知道 View 是何时创建的呢?或者这根本不可能。

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

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.

不,这是不可能的。

View 实际上并不包含数据,它只是由定义组成,即引用真实(物理)表中包含的数据的 SQL 语句:因此这就是INFORMATION_SCHEMA。 VIEWS 可以向您展示。

关于mysql/mariadb information_schema View 创建时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54471378/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com