我有一个名为app的表,我每周使用dataprep工作流来替换它。我需要在应用程序表中添加一列,显示该表的最后修改日期。我可以使用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
以公共数据集为例:
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