简体   繁体   中英

How to save query results in a Google Cloud Platform?

I have never used SQL before and I am trying to do something that should be simple, but it is taking hours to solve. I would like to download a table that is in a project at Google Cloud Platform. It is asked: "Choose where to save the results data from the query" and then I choose: "CSV(Google Drive) Save up to 1GB...". However, I get this message:

Table dataset_reference { project_reference { project_id: "escolas-259115" gaia_id: 777399094185 } dataset_id: "_31e2c29542f3fa3caf4d6d069271a277dce8d215" dataset_uuid: "9872dc9f-2c66-4088-b7b1-b949e7541f07" } table_id: "anon76eccaf0_a96b_4617_8a3c_c2d5ee734662" table_uuid: "76eccaf0-a96b-4617-8a3c-c2d5ee734662" too large to be exported to a single file. Specify a uri including a * to shard export. See 'Exporting data into one or more files' in https://cloud.google.com/bigquery/docs/exporting-data.

Here is the code that I am using:

SELECT
  ano,
  estado_abrev,
  id_municipio,
  causa_basica,
  idade,
  genero,
  raca_cor,
  numero_obitos
FROM
  `basedosdados.br_ms_sim.municipio_causa_idade_genero_raca`

As I said, I have never worked with SQL before.

What you try to achieve is for exporting the table. Here, you want to export a query result.

You can achieve this like that

EXPORT DATA OPTIONS(
  uri='gs://mybucket/transformed/sales-*.csv',
  format='CSV',
  overwrite=true,
  header=true,
  field_delimiter=';') AS
SELECT
  ano,
  estado_abrev,
  id_municipio,
  causa_basica,
  idade,
  genero,
  raca_cor,
  numero_obitos
FROM
  `basedosdados.br_ms_sim.municipio_causa_idade_genero_raca`

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