Skip to content Skip to sidebar Skip to footer

Select Table Name As A Column In Bigquery

I have a table in BigQuery, say table1 I want to be able to write SELECT table1.table_name as Table_Name from table_name How can I do this?

Solution 1:

I f you want rows and table names you can use meta tables __TABLES__:

SELECT 
  project_id, 
  dataset_id, 
  table_id, 
  row_count 
FROM 
  `bigquery-public-data.covid19_geotab_mobility_impact.__TABLES__` 
LIMIT 
  1000

Works with every dataset. These tables might get replaced with information schema tables in the future though https://cloud.google.com/bigquery/docs/information-schema-intro

Post a Comment for "Select Table Name As A Column In Bigquery"