如何为我的查询结果添加时间戳?

How do I add a timestamp to my query results?

我想在我的查询结果中添加一列,为返回的所有记录重复当前时间戳。这实际上是一个告诉您查询何时执行的列。

尝试使用 With、Union 和 Join...但似乎没有办法将 "print" 数据转化为 sql 尚未包含在数据库中的结果。

Select * from myTable
Union
select current_timestamp

打印 (select current_timestamp)

结果将是 table 的所有内容,外加一列 current_timestamp 用于返回所有记录。

如果你想要 current_timestamp 在每行结果形式 select 你应该只添加 col

Select *, current_timestamp  
from myTable

尝试:

Select * from myTable
Union
select current_timestamp as timeStamp

您需要将 TIMESTAMP 放入 select 子句中,如下所示 -

Select *,current_timestamp from myTable