为什么截断 table 不会更改最后的 DDL 日期?

Why truncate table does not change the Last DDL Date?

当我 运行 下面的代码时,我注意到 Last DDL Date 没有改变。

 execute immediate 'truncate table my_table';

有什么问题?

提前致谢

我找到了答案。

事情是:

Table is empty.

When a table is empty your truncate ddl does not change the Last DDL Date.

truncate table 仅在 table 不为空时截断它。

如果 table 为空,那么当您执行 truncate table 命令时它不会被截断。

在此处查看演示:

SQL> select OBJECT_NAME, LAST_DDL_TIME from user_objects where OBJECT_NAME = 'CONTR';

OBJECT_NAME  LAST_DDL_TIME
------------ --------------------
CONTR        13-nov-2019 11:45:53

SQL> truncate table CONTR; -- empty table

Table truncated.

SQL> select OBJECT_NAME, LAST_DDL_TIME from user_objects where OBJECT_NAME = 'CONTR';

OBJECT_NAME  LAST_DDL_TIME
------------ --------------------
CONTR        13-nov-2019 11:45:53

SQL> INSERT INTO CONTR VALUES (1,1,1,1); -- filling values in the table

1 row created.

SQL> commit;

Commit complete.

SQL> truncate table CONTR;

Table truncated.

SQL> select OBJECT_NAME, LAST_DDL_TIME from user_objects where OBJECT_NAME = 'CONTR';

OBJECT_NAME  LAST_DDL_TIME
------------ --------------------
CONTR        13-nov-2019 11:47:46

SQL> -- time is changed now

干杯!!