我想找到一个特定的时间戳之前创建的所有表和视图。对于表很容易,只是
SELECT * FROM information_schema.tables
WHERE table_type = 'TABLE' AND create_time < :ts
但意见也不是那么简单。该create_time
列为空在information_chema.tables
所有的意见。例如
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)
所以,我怎么能找到创建视图时?还是仅仅是不可能的。
不,这是不可能的。
视图实际上并不包含数据,它只是做了一个定义,即SQL语句所包含的实际(物理)表的引用数据:所以这是所有INFORMATION_SCHEMA.VIEWS
可以告诉你。