Deleting labels

You can delete a label from a dataset, table, or view by:

Before you begin

Grant Identity and Access Management (IAM) roles that give users the necessary permissions to perform each task in this document. The permissions required to perform a task (if any) are listed in the "Required permissions" section of the task.

Delete a dataset label

The following sections specify the permissions and steps for deleting a dataset label.

Required permissions

To delete a dataset label, you need the following IAM permissions:

  • bigquery.datasets.get
  • bigquery.datasets.update

Each of the following predefined IAM roles includes the permissions that you need in order to delete a dataset label:

  • roles/bigquery.dataOwner
  • roles/bigquery.admin

Additionally, if you have thebigquery.datasets.create permission, you can delete labels of the datasets that you create.

For more information on IAM roles and permissions inBigQuery, seePredefined roles and permissions.

Delete a dataset label

To delete a label from a dataset, choose one of the following options:

Console

  1. In the Google Cloud console, select the dataset.

  2. On the dataset details page, click the pencil icon to the right ofLabels.

    Label pencil

  3. In theEdit labels dialog:

    • For each label you want to delete, click delete (X).
    • To save your changes, clickUpdate.

SQL

Use theALTER SCHEMA SET OPTIONS DDL statementto set the labels on an existing dataset. Setting labels overwrites anyexisting labels on the dataset. The following example deletes all labels onthe datasetmydataset:

  1. In the Google Cloud console, go to theBigQuery page.

    Go to BigQuery

  2. In the query editor, enter the following statement:

    ALTERSCHEMAmydatasetSETOPTIONS(labels=[]);

  3. ClickRun.

For more information about how to run queries, seeRun an interactive query.

bq

To delete a dataset label, issue thebq update command with theclear_label flag. Repeat the flag to delete multiple labels.

If the dataset is in a project other than your default project, add theproject ID to the dataset in the following format:project_id:dataset.

bqupdate\--clear_labelkey\project_id:dataset

Where:

  • key is the key for a label that you want to delete.
  • project_id is your project ID.
  • dataset is the dataset you're updating.

Examples:

To delete thedepartment:shipping label frommydataset, enter thebq update command with the--clear_label flag.mydataset is in yourdefault project.

    bq update --clear_label department mydataset

To delete thedepartment:shipping label frommydataset inmyotherproject, enter thebq update command with the--clear_labelflag.

    bq update --clear_label department myotherproject:mydataset

To delete multiple labels from a dataset, repeat theclear_label flag andspecify each label's key. For example, to delete thedepartment:shippinglabel andcost_center:logistics labels frommydataset in your defaultproject, enter:

    bq update \    --clear_label department \    --clear_label cost_center \    mydataset

For each of these examples, the output looks like the following:

Dataset 'myproject:mydataset' successfully updated.

API

To delete a particular label for an existing dataset, call thedatasets.patchmethod and update thelabelsproperty for thedataset resourceby setting the label's key value tonull.

To delete all labels from a dataset, call thedatasets.patchmethod and delete thelabels property.

Because thedatasets.update method replaces the entire dataset resource,thedatasets.patch method is preferred.

Go

Before trying this sample, follow theGo setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryGo API reference documentation.

To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

import("context""fmt""cloud.google.com/go/bigquery")// deleteDatasetLabel demonstrates removing a specific label from a dataset's metadata.funcdeleteDatasetLabel(projectID,datasetIDstring)error{// projectID := "my-project-id"// datasetID := "mydataset"ctx:=context.Background()client,err:=bigquery.NewClient(ctx,projectID)iferr!=nil{returnfmt.Errorf("bigquery.NewClient: %v",err)}deferclient.Close()ds:=client.Dataset(datasetID)meta,err:=ds.Metadata(ctx)iferr!=nil{returnerr}update:=bigquery.DatasetMetadataToUpdate{}update.DeleteLabel("color")if_,err:=ds.Update(ctx,update,meta.ETag);err!=nil{returnerr}returnnil}

Java

Before trying this sample, follow theJava setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryJava API reference documentation.

To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

importcom.google.cloud.bigquery.BigQuery;importcom.google.cloud.bigquery.BigQueryException;importcom.google.cloud.bigquery.BigQueryOptions;importcom.google.cloud.bigquery.Dataset;importjava.util.HashMap;importjava.util.Map;// Sample tp deletes a label on a dataset.publicclassDeleteLabelDataset{publicstaticvoidrunDeleteLabelDataset(){// TODO(developer): Replace these variables before running the sample.StringdatasetName="MY_DATASET_NAME";deleteLabelDataset(datasetName);}publicstaticvoiddeleteLabelDataset(StringdatasetName){try{// Initialize client that will be used to send requests. This client only needs to be created// once, and can be reused for multiple requests.BigQuerybigquery=BigQueryOptions.getDefaultInstance().getService();// This example dataset starts with existing label { color: 'green' }Datasetdataset=bigquery.getDataset(datasetName);// Add label to datasetMap<String,String>labels=newHashMap<>();labels.put("color",null);dataset.toBuilder().setLabels(labels).build().update();System.out.println("Dataset label deleted successfully");}catch(BigQueryExceptione){System.out.println("Dataset label was not deleted. \n"+e.toString());}}}

Node.js

Before trying this sample, follow theNode.js setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryNode.js API reference documentation.

To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

// Import the Google Cloud client libraryconst{BigQuery}=require('@google-cloud/bigquery');constbigquery=newBigQuery();asyncfunctiondeleteLabelDataset(){// Deletes a label on a dataset.// This example dataset starts with existing label { color: 'green' }/**   * TODO(developer): Uncomment the following lines before running the sample.   */// const datasetId = 'my_dataset';// Retrieve current dataset metadata.constdataset=bigquery.dataset(datasetId);const[metadata]=awaitdataset.getMetadata();// Add label to dataset metadatametadata.labels={color:null};const[apiResponse]=awaitdataset.setMetadata(metadata);console.log(`${datasetId} labels:`);console.log(apiResponse.labels);}

Python

Before trying this sample, follow thePython setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryPython API reference documentation.

To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

fromgoogle.cloudimportbigquery# Construct a BigQuery client object.client=bigquery.Client()# TODO(developer): Set dataset_id to the ID of the dataset to fetch.# dataset_id = "your-project.your_dataset"dataset=client.get_dataset(dataset_id)# Make an API request.# To delete a label from a dataset, set its value to None.dataset.labels["color"]=Nonedataset=client.update_dataset(dataset,["labels"])# Make an API request.print("Labels deleted from{}".format(dataset_id))

Delete a table or view label

You can delete a table or view label in the following ways:

  • Using the Google Cloud console
  • Using SQLDDL statements
  • Using the bq command-line tool'sbq update command
  • Calling thetables.patchAPI method
    • Because views are treated like table resources,tables.patch is used tomodify both views and tables.
  • Using the client libraries

Required permissions

To delete a table or view label, you need the following IAM permissions:

  • bigquery.tables.get
  • bigquery.tables.update

Each of the following predefined IAM roles includes the permissions that you need in order to delete a table or view label:

  • roles/bigquery.dataEditor
  • roles/bigquery.dataOwner
  • roles/bigquery.admin

Additionally, if you have thebigquery.datasets.create permission, you can delete labels of the tables and views in the datasets that you create.

For more information on IAM roles and permissions inBigQuery, seePredefined roles and permissions.

Delete a table or view label

To delete a label from a table or view, choose one of the following options:

Console

  1. In the Google Cloud console, select the dataset.

  2. Click theDetails tab, and then click the pencil icon to theright ofLabels.

    Label pencil

  3. In theEdit labels dialog:

    • For each label you want to delete, click delete (X).

      Label delete

    • To save your changes, clickUpdate.

SQL

Use theALTER TABLE SET OPTIONS DDL statement to set the label on an existing table, or theALTER VIEW SET OPTIONS DDL statementto set the label on an existing view. Setting labels overwrites anyexisting labels on the table or view. The following example deletes alllabels from the tablemytable:

  1. In the Google Cloud console, go to theBigQuery page.

    Go to BigQuery

  2. In the query editor, enter the following statement:

    ALTERTABLEmydataset.mytableSETOPTIONS(labels=[]);

  3. ClickRun.

For more information about how to run queries, seeRun an interactive query.

bq

To delete a label from a table or view, issue thebq update command withtheclear_label flag. Repeat the flag to delete multiple labels.

If the table or view is in a project other than your default project, addthe project ID to the dataset in the following format:project_id:dataset.

bqupdate\--clear_labelkey\project_id:dataset.table_or_view

Where:

  • key is the key for a label that you want to delete.
  • project_id is your project ID.
  • dataset is the dataset you're updating.
  • table_or_view is the name of the table or view you're updating.

Examples:

To delete thedepartment:shipping label frommydataset.mytable, enterthebq update command with the--clear_label flag.mydataset is inyour default project.

    bq update --clear_label department mydataset.mytable

To delete thedepartment:shipping label frommydataset.myview inmyotherproject, enter thebq update command with the--clear_labelflag.

    bq update --clear_label department myotherproject:mydataset.myview

To delete multiple labels from a table or view, repeat theclear_labelflag and specify each label's key. For example, to delete thedepartment:shipping label andcost_center:logistics label frommydataset.mytable in your default project, enter:

    bq update \    --clear_label department \    --clear_label cost_center \    mydataset.mytable

For each of these examples, the output looks like the following:

Table 'myproject:mydataset.mytable' successfully updated.

API

To delete a particular label for an existing table or view, call thetables.patchmethod and update thelabelsproperty for thetable resourceby setting the label's key value tonull.

To delete all labels from a table or view, call thetables.patchmethod and delete thelabels property.

Because views are treated like table resources, you use thetables.patchmethod to modify both views and tables. Also, because thetables.updatemethod replaces the entire dataset resource, thetables.patch method ispreferred.

Go

Before trying this sample, follow theGo setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryGo API reference documentation.

To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

import("context""fmt""cloud.google.com/go/bigquery")// deleteTableLabel demonstrates how to remove a specific metadata Label from a BigQuery table.funcdeleteTableLabel(projectID,datasetID,tableIDstring)error{// projectID := "my-project-id"// datasetID := "mydataset"// tableID := "mytable"ctx:=context.Background()client,err:=bigquery.NewClient(ctx,projectID)iferr!=nil{returnfmt.Errorf("bigquery.NewClient: %v",err)}deferclient.Close()tbl:=client.Dataset(datasetID).Table(tableID)meta,err:=tbl.Metadata(ctx)iferr!=nil{returnerr}update:=bigquery.TableMetadataToUpdate{}update.DeleteLabel("color")if_,err:=tbl.Update(ctx,update,meta.ETag);err!=nil{returnerr}returnnil}

Java

Before trying this sample, follow theJava setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryJava API reference documentation.

To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

importcom.google.cloud.bigquery.BigQuery;importcom.google.cloud.bigquery.BigQueryException;importcom.google.cloud.bigquery.BigQueryOptions;importcom.google.cloud.bigquery.Table;importcom.google.cloud.bigquery.TableId;importjava.util.HashMap;importjava.util.Map;// Sample tp deletes a label on a table.publicclassDeleteLabelTable{publicstaticvoidrunDeleteLabelTable(){// TODO(developer): Replace these variables before running the sample.StringdatasetName="MY_DATASET_NAME";StringtableName="MY_TABLE_NAME";deleteLabelTable(datasetName,tableName);}publicstaticvoiddeleteLabelTable(StringdatasetName,StringtableName){try{// Initialize client that will be used to send requests. This client only needs to be created// once, and can be reused for multiple requests.BigQuerybigquery=BigQueryOptions.getDefaultInstance().getService();// This example table starts with existing label { color: 'green' }Tabletable=bigquery.getTable(TableId.of(datasetName,tableName));// Add label to tableMap<String,String>labels=newHashMap<>();labels.put("color",null);table.toBuilder().setLabels(labels).build().update();System.out.println("Table label deleted successfully");}catch(BigQueryExceptione){System.out.println("Table label was not deleted. \n"+e.toString());}}}

Node.js

Before trying this sample, follow theNode.js setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryNode.js API reference documentation.

To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

// Import the Google Cloud client libraryconst{BigQuery}=require('@google-cloud/bigquery');constbigquery=newBigQuery();asyncfunctiondeleteLabelTable(){// Deletes a label from an existing table.// This example dataset starts with existing label { color: 'green' }/**   * TODO(developer): Uncomment the following lines before running the sample.   */// const datasetId = "my_dataset";// const tableId = "my_table";constdataset=bigquery.dataset(datasetId);const[table]=awaitdataset.table(tableId).get();// Retrieve current table metadataconst[metadata]=awaittable.getMetadata();// Add label to table metadatametadata.labels={color:null};const[apiResponse]=awaittable.setMetadata(metadata);console.log(`${tableId} labels:`);console.log(apiResponse.labels);}

Python

Before trying this sample, follow thePython setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryPython API reference documentation.

To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

fromgoogle.cloudimportbigqueryclient=bigquery.Client()# TODO(dev): Change table_id to the full name of the table you wish to delete from.table_id="your-project.your_dataset.your_table_name"# TODO(dev): Change label_key to the name of the label you want to remove.label_key="color"table=client.get_table(table_id)# API request# To delete a label from a table, set its value to Nonetable.labels[label_key]=Nonetable=client.update_table(table,["labels"])# API requestprint(f"Deleted label '{label_key}' from{table_id}.")

Delete a reservation label

You can delete a reservation label.

Required IAM roles

To get the permission that you need to delete a reservation label, ask your administrator to grant you theBigQuery Resource Editor (roles/bigquery.resourceEditor) IAM role on the administration project. For more information about granting roles, seeManage access to projects, folders, and organizations.

This predefined role contains the bigquery.reservations.delete permission, which is required to delete a reservation label.

You might also be able to get this permission withcustom roles or otherpredefined roles.

Delete a reservation label

To delete a label from a reservation, choose one of the following options:

SQL

To delete a reservation label, use theALTER RESERVATION SET OPTIONS DDLstatement.To delete the labels on a reservation, set the labels to an empty array. Thefollowing example deletes the label on the reservationmyreservation:

  1. In the Google Cloud console, go to theBigQuery page.

    Go to BigQuery

  2. In the query editor, enter the following statement:

    ALTERRESERVATIONmyreservationSETOPTIONS(labels=[]);

  3. ClickRun.

For more information about how to run queries, seeRun an interactive query.

bq

To delete a reservation label, issue thebq update command with theclear_label flag and--reservation flag. To delete multiple labels, repeatthe flag.

bqupdate--clear_labelKEY--reservationRESERVATION_NAME

Replace the following:

  • KEY: a key for a label that youwant to delete to the reservation. The key must be unique. Keys and values cancontain only lowercase letters, numeric characters, underscores, anddashes. All characters must use UTF-8 encoding, and internationalcharacters are allowed. To delete multiple labels to a reservation, repeat the--clear_label flag and specify a unique keyfor each label.
  • RESERVATION_NAME: the name of the reservation.

Delete job labels

Deleting a label from an existing job is not supported.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-18 UTC.