在Google Big Query中,我需要提取给定数据集中所有表的最后更新日期。所以我需要的输出是<<TableName>> <<Last Update Date>>
我知道如何列出表格:
#standardSQL
SELECT
table_id,
row_count
FROM `myproject.mydataset.__TABLES__`
WHERE table_id IN ('TABLEA', 'TABLEB', 'TABLEC')
如何获取上次更新日期而不是row_count?
由于
答案 0 :(得分:3)
请尝试以下
如果我正确地理解了这个问题 - 它有你要求的内容以及更多
#standardSQL
SELECT table_id,
DATE(TIMESTAMP_MILLIS(creation_time)) AS creation_date,
DATE(TIMESTAMP_MILLIS(last_modified_time)) AS last_modified_date,
row_count,
size_bytes,
CASE
WHEN type = 1 THEN 'table'
WHEN type = 2 THEN 'view'
WHEN type = 3 THEN 'external'
ELSE '?'
END AS type,
TIMESTAMP_MILLIS(creation_time) AS creation_time,
TIMESTAMP_MILLIS(last_modified_time) AS last_modified_time,
dataset_id,
project_id
FROM `myproject.mydataset.__TABLES__`