Truncate a table in GBQ

While BigQuery didn't used to support anything other than SELECTs, it now does as long as you uncheck "Use Legacy SQL" in the query options. There is no truncation, but you can delete:

DELETE from my_table WHERE 1=1

Note that BigQuery requires the use of WHERE in the DELETE, so if you want to delete everything you need to use a statement that will always be true.


Good news, TRUNCATE TABLE is supported by now: https://cloud.google.com/bigquery/docs/reference/standard-sql/dml-syntax#truncate_table_statement

TRUNCATE TABLE [[project_name.]dataset_name.]table_name

However, please note that this will not work / is not supported, if a partition filter is required through your table definition.


CREATE OR REPLACE TABLE <dataset>.<table>
AS SELECT * FROM <dataset>.<table> LIMIT 0;

For partitionned tables, assuming you have a day partition on field "created_on", then execute the following :

CREATE OR REPLACE TABLE <dataset>.<table> PARTITION BY created_on
AS SELECT * FROM <dataset>.<table> WHERE created_on = CURRENT_DATE() LIMIT 0;