I'm looking for an option to remove a column from my BigQuery table like ALTER TABLE TABLE_NAME DROP COLUMN_NAME
- but all I found in online was, drop the old table and create a new one.
I'm just wondering, Is there any logical reason not having this option in BigQuery?
BigQuery has supported Data Manipulation Language (DML) functionality since 2016 for standard SQL, which enables you to insert, update, and delete rows and columns in your BigQuery datasets.
You need to understand that BigQuery cannot be used to substitute a relational database, and it is oriented on running analytical queries, not for simple CRUD operations and queries.
Dropping a column would mean removing the data from all of the Capacitor files that make up the table, which is an expensive operation. If BigQuery were simply to remove metadata related to the column, you would be charged storage for a phantom column that you can't actually query, which wouldn't be ideal.
When you add a column, conversely, BigQuery treats the missing column in past files as having all NULL
values, which doesn't require modifying them.
There are a couple of different options to remove a column:
You could remove column via re-writing table.
CREATE OR REPLACE TABLE
temp.table_name AS
SELECT
* EXCEPT (column_name)
FROM
temp.table_name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With