The ALTER MODEL statement
To update a model in BigQuery, use the BigQuery MLALTERMODEL statement.
For more information about supported SQL statements and functions for differentmodel types, see the following documents:
- End-to-end user journeys for generative AI models
- End-to-end user journeys for time series forecasting models
- End-to-end user journeys for ML models
- End-to-end user journeys for imported models
ALTER MODEL syntax
ALTER MODEL [IF EXISTS]`PROJECT_ID.DATASET.MODEL`SET OPTIONS ( [vertex_ai_model_id =VERTEX_MODEL_ID] [, expiration_timestamp =EXPIRATION_TIMESTAMP] [, kms_key_name =KMS_KEY_NAME] [, description =DESCRIPTION] [, labels =LABELS] [, deploy_model =DEPLOY_MODEL] [, endpoint_idle_ttl =ENDPOINT_IDLE_TTL] );
Arguments
PROJECT_ID: the project that contains theresource.DATASET: the dataset that contains theresource.MODEL: the name of the model you're creating orreplacing. The model name must be unique in the dataset: no other model ortable can have the same name. The model name must follow the same naming rulesas a BigQuery table. A model name can:- Contain up to 1,024 characters
- Contain letters (upper or lower case), numbers, and underscores
MODELis case-sensitive.If you don't have a default project configured, then you must prepend theproject ID to the model name in the following format, including backticks:
`[PROJECT_ID].[DATASET].[MODEL]`
For example, `myproject.mydataset.mymodel`.
VERTEX_MODEL_ID: aSTRINGvalue that specifiesthe Vertex AI model ID to register the model with. To learn more, seeRegister an existing BigQuery ML model to the Model Registry.EXPIRATION_TIMESTAMP: aTIMESTAMPvalue thatspecifies when this model expires. If the model is anopen model that BigQuery manages in Vertex AI,all Vertex AI resources associated with the model are deletedwhen the model expires.KMS_KEY_NAME: aSTRINGvalue that specifiesthe name of the Cloud KMS key used to encrypt the model.DESCRIPTION: aSTRINGvalue that provides adescription of the model.LABELS: anARRAY<STRUCT<STRING, STRING>>valuethat specifies any labels for the model askey,valuepairs.DEPLOY_MODEL: aBOOLvaluethat determines the model's deployment status in Vertex AI. You canuse this option to control costs by undeploying or redeploying the modelas needed. We recommend undeploying an unused Vertex AI endpoint,because otherwise the endpoint continues to generate charges for the computeresources that it uses, even when it is idle. For more information onVertex AI compute pricing, seePrediction and explanation.You can only use this option with anopen model that BigQuery manages in Vertex AI(Preview).
If the model was previously undeployed, setting this option to
TRUEredeploys the model to a Vertex AI endpoint. If the modelis already deployed, this operation has no effect. Model redeploymentrequires a "cold start" period while the endpoint resources are provisioned.The cold start period can take up to 30 minutes, depending on the size of themodel and the number ofmachine replicasspecified for the model.Setting this option to
FALSEundeploys the model from aVertex AI endpoint. If the model is already undeployed, thisoperation has no effect.ENDPOINT_IDLE_TTL: anINTERVALvalue thatspecifies the duration of inactivity after which the model isautomatically undeployed from the Vertex AI endpoint.You can only use this option with anopen model that BigQuery manages in Vertex AI(Preview).To enable automatic undeployment, specify aninterval literalvalue between 390 minutes (6.5 hours) and 7 days. For example, specify
INTERVAL 8 HOURto have the model undeployed after 8 hours of idleness.The default value is 390 minutes (6.5 hours).Model inactivity is defined as the amount of time that has passedsince the any of the following operations were performed on the model:
- Running the
CREATE MODELstatement. - Running the
ALTER MODELstatement with theDEPLOY_MODELargument settoTRUE. - Sending an inference request to the model endpoint. For example, byrunning the
AI.GENERATE_EMBEDDINGorAI.GENERATE_TEXTfunction.
Each of these operations resets the inactivity timer to zero. The reset istriggered at the start of the BigQuery job that performs theoperation.
After the model is undeployed, inference requests sent to the model returnan error. The BigQuery model object remains unchanged,including model metadata. To use the model for inference again, you mustredeploy it by running the
ALTER MODELstatement on the model andsetting theDEPLOY_MODELoption toTRUE.- Running the
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 2025-12-15 UTC.