我有一个名为apps的表,我每周使用dataprep工作流来代替它。我需要在apps表中添加一列,以显示该表的最后修改日期。我可以使用Information_schema来获取此信息,但不确定如何将上次修改日期添加到现有表应用程序中。
我尝试使用Information_schema来获取表名和上次修改日期,但是需要在下面的代码中将此日期作为last_modified包括到我现有的表中。我需要在表格中插入最后修改日期的列
SELECT *
FROM
`xxx.xxx.Apps`
LIMIT 10
SELECT *, DATE(TIMESTAMP_MILLIS(last_modified_time)) AS
last_modified_date
FROM
`xxx.xxx.Apps`
LIMIT 10
答案 0 :(得分:0)
以公共数据集为例:
DECLARE last_modified_time DATE DEFAULT
(SELECT DATE(TIMESTAMP_MILLIS(last_modified_time)) FROM `bigquery-public-data.crypto_bitcoin.__TABLES__`
WHERE table_id = 'blocks');
SELECT *, last_modified_time
FROM `bigquery-public-data.crypto_bitcoin.blocks` LIMIT 1
或者,使用子查询的单个语句
WITH last_modified_time as
(SELECT DATE(TIMESTAMP_MILLIS(last_modified_time)) FROM `bigquery-public-data.crypto_bitcoin.__TABLES__`
WHERE table_id = 'blocks')
SELECT *, (SELECT * FROM last_modified_time)
FROM `bigquery-public-data.crypto_bitcoin.blocks` LIMIT 1