Basics
Database Management
Dates and Times
How to Create a Table in BigQuery
BigQuery is Google Cloud’s powerful data warehouse for large-scale data analytics. In this tutorial, you will learn how to create a table in BigQuery using three methods: the Google Cloud Console, SQL, and the command-line interface (CLI).
1. Create a Table Using the Cloud Console
- Go to the BigQuery Console.
- In the Explorer panel, select your project and dataset, then click Create Table.
- Choose the Source (e.g., Empty table, Upload, Google Cloud Storage, etc.).
- Enter a Table name and define the Schema (manually or auto-detect).
- Set any additional options (Partitioning, Clustering, Encryption).
- Click Create Table.
2. Create a Table Using SQL
CREATE TABLE dataset_name.table_name (
column1 STRING,
column2 INT64,
column3 TIMESTAMP
);
Run this SQL command in the BigQuery Editor or through the API to create a table with defined columns.
3. Create a Table Using the CLI
bq mk --table project_id:dataset_name.table_name column1:STRING,column2:INT64,column3:TIMESTAMP
Use the bq
command-line tool to quickly create tables from your terminal or scripts.
Final Tips
- Always double-check your dataset and table names.
- Use partitioning and clustering to improve query performance on large datasets.
- Test your schema with a small dataset before production.
For more details, see the BigQuery Table Documentation.