Thursday, 5 June 2025

Deleting a Column in BigQuery

In BigQuery, you can delete an existing column from a table using the DROP COLUMN statement. This operation permanently removes the column and its data, so it should be done carefully. 

SQL Command to Delete a Column

To delete a column, use the following SQL syntax:

ALTER TABLE project.dataset.table_name 
DROP COLUMN column_name;


 

For example, if you want to delete the email column from a table named employees: 

ALTER TABLE myProject.myDataset.employees 
DROP COLUMN mail;

Upon successful execution of above statement, you can observe that the mail column is deleted from employees table.

 


Points to Note

·      You cannot delete a column if it is the only column in the table.

·      Once a column is dropped, the data in that column is permanently lost.

·      Dropping a column does not affect other columns or table structure.

 

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment