google-big-queryHow do I create and use Google BigQuery datasets?
Creating and using Google BigQuery datasets is a simple process.
-
First, create a project in the Google Cloud Console.
-
Then, in the BigQuery section, create a new dataset.
-
You can now upload or stream data into the dataset. For example, to upload a CSV file, you can use the following code:
# Standard SQL
CREATE OR REPLACE TABLE your_dataset.your_table
# Legacy SQL
CREATE TABLE your_dataset.your_table
# Uploading the CSV
WITH data AS (
SELECT * FROM
CSV_LOAD('gs://your_bucket/your_file.csv',
FORMAT='CSV',
AUTODETECT=TRUE)
)
INSERT INTO your_dataset.your_table
SELECT * FROM data
-
Once the data is uploaded, you can query it using Standard SQL or Legacy SQL.
-
You can also export the data in CSV, JSON, or Avro formats. For example, to export a table in CSV format, you can use the following code:
# Standard SQL
SELECT * FROM your_dataset.your_table
INTO OUTFILE 'gs://your_bucket/your_file.csv'
FORMAT CSV
# Legacy SQL
SELECT * FROM your_dataset.your_table
INTO OUTFILE 'gs://your_bucket/your_file.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
-
Finally, you can delete the dataset when you no longer need it.
-
For more information, you can refer to the BigQuery documentation.
More of Google Big Query
- How can I use Google Big Query to count the number of zeros in a given dataset?
- ¿Cuáles son las ventajas y desventajas de usar Google BigQuery?
- How can I use Google Big Query to analyze Reddit data?
- How can I learn to use Google BigQuery?
- How do I use Google Big Query with Excel?
- How can I export data from Google Big Query to an XLSX file?
- How can I use Google BigQuery on a Windows system?
- How do Google BigQuery and Azure compare in terms of performance and cost?
- How do I start using Google Big Query?
- How do I use Google BigQuery language to query data?
See more codes...