How to rename a column name in Google Bigquery table - with Examples
Bigquery doesnt support altering table definitions, But it does allow you to replace tables. You can use this feature to rename a column in Google Bigquery:
Example: Lets consider you want to rename two columns, EId into EmpId and Enm into Emp_Name, you can use the below SQL to alter the columns.
- Make sure to include all the columns from the table in the select list
- Use aliases for the columns that needs to be renamed
create or replace table `mydataset.Employee` as
SELECT EId as EmpId, Enm as Emp_Name, Emp_Location FROM `mydataset.Employee`;
This will create the new table with the new column names as well as copy the data from the old to the new version of the table.
Enjoy great content like this and a lot more !
Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds