Stay organized with collections Save and categorize content based on your preferences.
Delete modelsThis page shows you how to delete BigQuery ML models. You can delete a model by:
bq rm
command or bq query
commandmodels.delete
API method or calling the jobs.query
methodYou can only delete one model at a time. When you delete a model, any data in the model is also deleted.
To automatically delete models after a specified period of time, set the model's expiration time when you create it using the bq command-line tool, the API, or the client libraries. If you did not set the expiration when the model was created, you can update the model's expiration time.
Limitations on deleting modelsDeleting a model is subject to the following limitations:
To delete models in a dataset, you must be assigned the WRITER
role on the dataset, or you must be assigned a project-level Identity and Access Management (IAM) role that includes bigquery.models.delete
permissions. If you are granted bigquery.models.delete
permissions at the project level, you can delete models in any dataset in the project. The following project-level IAM roles include bigquery.models.delete
permissions:
bigquery.dataEditor
bigquery.dataOwner
bigquery.admin
For more information about IAM roles and permissions in BigQuery ML, see Access control.
Delete a modelTo delete a model, do the following:
ConsoleYou can delete a model in the Google Cloud console by using the Delete Model option or by running a query that contains a DROP MODEL | DROP MODEL IF EXISTS
DDL statement.
Option one: Use the Delete Model option.
In the Explorer pane, expand your project and then expand a dataset.
Expand the Models folder in the dataset, and then click a model name to select the model.
Click the options icon more_vert for the model and then click Delete.
In the Delete model dialog, type delete
and then click Delete.
Option two: Use a DDL statement.
In the Google Cloud console, go to the BigQuery page.
Click Compose new query.
Type your DDL statement in the Query editor text area.
DROP MODEL mydataset.mymodel
Click Run. When the query completes, the model is removed from the navigation pane.
You can delete a model using the bq command-line tool by entering the:
bq rm
command with the --model
or -m
flagbq query
command with the DDL statement as the query parameterIf you are deleting a model in a project other than your default project, add the project ID to the dataset in the following format: [PROJECT_ID]:[DATASET].[MODEL]
.
Option one: Enter the bq rm
command
When you use the bq rm
command to remove a model, you must confirm the action. You can use the --force flag
(or -f
shortcut) to skip confirmation.
bq rm -f --model PROJECT_ID:DATASET.MODEL
Replace the following:
PROJECT_ID
is your project ID.DATASET
is the name of the dataset.MODEL
is the name of the model.The rm
command produces no output.
Examples:
Enter the following command to delete mymodel
from mydataset
. mydataset
is in your default project.
bq rm --model mydataset.mymodel
Enter the following command to delete mymodel
from mydataset
. mydataset
is in myotherproject
, not your default project.
bq rm --model myotherproject:mydataset.mymodel
Enter the following command to delete mymodel
from mydataset
. mydataset
is in your default project. The command uses the -f
shortcut to bypass confirmation.
bq rm -f --model mydataset.mymodel
You can confirm that the model was deleted by issuing the bq ls
command. For more information, see List models.
Option two: Enter the bq query
command
To delete a model by using the bq query
command, supply the DROP MODEL
statement in the query parameter and supply the --use_legacy_sql=false
flag to specify GoogleSQL query syntax.
Examples:
Enter the following command to delete mymodel
from mydataset
. mydataset
is in your default project.
bq query --use_legacy_sql=false 'DROP MODEL mydataset.mymodel'
Enter the following command to delete mymodel
from mydataset
. mydataset
is in myotherproject
, not your default project.
bq query --use_legacy_sql=false \
'DROP MODEL myotherproject:mydataset.mymodel'
API
Option one: Call the models.delete
method
To delete a model, call the models.delete
method and provide the projectId
, datasetId
, and modelId
.
Option two: Call the jobs.query
method
To delete a model, call the jobs.query
method and supply the DROP MODEL
DDL statement in the request body's query property.
Before trying this sample, follow the Go setup instructions in the BigQuery quickstart using client libraries. For more information, see the BigQuery Go API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
JavaBefore trying this sample, follow the Java setup instructions in the BigQuery quickstart using client libraries. For more information, see the BigQuery Java API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Node.jsBefore trying this sample, follow the Node.js setup instructions in the BigQuery quickstart using client libraries. For more information, see the BigQuery Node.js API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
PythonBefore trying this sample, follow the Python setup instructions in the BigQuery quickstart using client libraries. For more information, see the BigQuery Python API reference documentation.
To authenticate to BigQuery, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
Restore a deleted modelYou can't restore a deleted model.
What's nextExcept as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["You can delete BigQuery ML models using the Google Cloud console, the `bq` command-line tool, API methods, or client libraries, but only one model at a time."],["Deleting a model permanently removes all associated data, and once deleted, a model cannot be restored."],["To delete a model, users must have the `WRITER` role on the dataset or an IAM role including `bigquery.models.delete` permissions at the project level."],["Models can be set to automatically expire after a specific time, and you can update a models expiration time if it was not set during creation."],["The methods to delete a model include using the `bq rm` command or the `bq query` command with a `DROP MODEL` statement, as well as using the console's delete option or calling the `models.delete` or `jobs.query` API methods."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4