BigQuery - remove unused column from schema

后端 未结 3 779
囚心锁ツ
囚心锁ツ 2021-02-13 17:45

I accidentally added a wrong column to my BigQuery table schema.

Instead of reloading the complete table (million of rows), I would like to know if the following is poss

3条回答
  •  鱼传尺愫
    2021-02-13 18:16

    Below is the code to do it. Lets say c is the column that you wants to delete.

    CREATE OR REPLACE TABLE transactions.test_table AS
    SELECT * EXCEPT (c) FROM  transactions.test_table;
    

    Or second method and my favorite is by following below steps.

    1. Write Select query with the columns you want to exclude.
    2. Go to Query Settings Query Settings
    3. In Destination setting Set destination table for query results, enter project name, Dataset name and table name exactly same as you entered in Step 1.
    4. In Destination table write preference select Overwrite table. Destination table settings
    5. Save the Query Setting and run the query.

提交回复
热议问题