是否可以从 MySQL 或 Oracle 服务器读取在特定时间戳之后创建的记录,即使没有时间戳列?

Is it possible to read records from a MySQL or Oracle Server which were created after a specific Timestamp, even if there is no Timestamp column?

如果 table 没有时间戳列,我必须从远程 MySQL 服务器 periodically.Say 读取,有没有办法跟踪我已经read.I只需要读取我上次访问后创建的行。

在 Oracle 中,我们可以使用 SCN 通过 ora_rowscn 伪列来解决这个问题。这使我们能够确定更新行的时间。还有一个简洁的 scn_to_timestamp() 函数。

Select scn_to_timestamp(ora_rowscn),
   t.*
from your_table t
where t.id = 23;

这只是大概时间,因为默认情况下 Oracle 在块级别跟踪 SCN。如果 table 启用了行级依赖项,您可以获得较低粒度级别的 SCN。 Find out more

如果表在 Oracle 中,一种方法是启用闪回查询,然后您可以这样做:

SELECT *
FROM   your_table t
WHERE  NOT EXISTS (
  SELECT 1
  FROM   your_table AS OF TIMESTAMP SYSTIMESTAMP - INTERVAL '10' MINUTE x
  WHERE  t.primary_key_column = x.primary_key_column
);