Truncate a table in GBQ

前端 未结 4 886
粉色の甜心
粉色の甜心 2021-02-02 11:21

I am trying to truncate an existing table in GBQ but the below command fails when I run it. Is there any specific command or syntax to do that. I looked into GBQ documentation b

4条回答
  •  孤城傲影
    2021-02-02 11:57

    EDIT (Nov 2020): BigQuery now supports other verbs, check other answers for newer solutions.

    BigQuery doesn't support TRUNCATE as part of a query string. The only DDL/DML verb that BQ supports is SELECT.

    One option is to run a job with WRITE_TRUNCATE write disposition (link is for the query job parameter, but it's supported on all job types with a destination table). This will truncate all data already in the table and replace it with the results of the job.

    If you don't want to replace the contents with other data or start a job, your best option is probably to delete and recreate the table with the same schema.

提交回复
热议问题