简体   繁体   中英

Merging two queries in bigquery

I need to get table_schemna, table_name, creation_time and last modified time columns

using this query i am not getting table_name.

SELECT * FROM `region`.INFORMATION_SCHEMA.SCHEMATA;

using this query i am not getting Last modified time.

SELECT * FROM `region`.INFORMATION_SCHEMA.TABLES;

Is this possible to merge the above queries to get the required four columns or is there any other way to get the last_modified time,creation time, table from multiple datasets

I did a simple join query with your requirements.

Query:

SELECT table_schema,table_name,a.creation_time,last_modified_time FROM <projectID>.`region-us`.INFORMATION_SCHEMA.TABLES a
INNER JOIN region-us.INFORMATION_SCHEMA.SCHEMATA on schema_name = table_schema ;

Just apply the project ID and and proper region where your BQ dataset is situated. (Also apply proper role to access the tables schema)

Sample Output: 在此处输入图像描述

You can consider the below approach to get the table_id, creation time and last_modified time from datasets.

select table_id, TIMESTAMP_MILLIS(creation_time) AS creation_time,
TIMESTAMP_MILLIS(last_modified_time) AS last_modified_time,
dataset_id
FROM `project.dataset.__TABLES__`

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM