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
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.