簡體   English   中英

如何在查詢結果中添加時間戳?

[英]How do I add a timestamp to my query results?

我想在查詢結果中添加一列,以對返回的所有記錄重復當前時間戳。 這實際上將是一列,告訴您何時執行查詢。

嘗試使用With,Union和Join ...,但似乎沒有一種方法可以將數據“打印”到數據庫中尚未包含的sql結果中。

Select * from myTable
Union
select current_timestamp

打印(選擇current_timestamp)

結果將是表的所有內容,並帶有一個額外的列,該列具有針對所有返回的記錄的current_timestamp。

如果要在結果表格的每一行上使用current_timestamp,請僅添加列

Select *, current_timestamp  
from myTable

嘗試:

Select * from myTable
Union
select current_timestamp as timeStamp

您需要將TIMESTAMP放在select子句中,如下所示-

Select *,current_timestamp from myTable

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM