在google-bigquery中,如何按大小排列表格列表?

时间:2017-08-23 21:20:22

标签: google-bigquery

我需要按大小列出数据集顺序中的所有BQ表,以找出占用更多空间的表。怎么做到这一点?

谢谢!

1 个答案:

答案 0 :(得分:5)

  
#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 `yourProject.yourDataset.__TABLES__`
ORDER BY size_bytes DESC  

以上查询为您提供的不仅仅是尺寸 - 享受:o)