Skip to main content


Modifies a model


ALTER MODEL model-name PURGE [ ALL ] [ integer DAYS ]  
ALTER MODEL model-name DEFAULT [ TRAINED MODEL ] trained-model-name


model-name The name of the machine learning model to alter.
DEFAULT trained-model-name A trained machine learning model.
integer DAYS An integer.


An ALTER MODEL statement modifies a machine learning model. You can perform only one type of operation in each ALTER MODEL statement.

  • A PURGE deletes all training runs and validation runs for the associated model based on the given scope:

    • If no scope is given, all records are deleted except for those associated with the default trained model.

    • If integer DAYS is given, all records older than integer days are deleted.

    • If ALL is given, all records are deleted regardless of when they occurred.

  • A DEFAULT (or DEFAULT TRAINED MODEL) sets the default trained model to be the model specified. This is useful when you have made several TRAIN MODEL statements using the same model definition, saving each trained model to a different name, and you wish to switch which model the default name points to. Specifying a nonexistent model results in an error.

Required Security Privileges

Calling ALTER MODEL requires %MANAGE_MODEL privileges; otherwise, there is a SQLCODE –99 error (Privilege Violation). To assign %MANAGE_MODEL privileges, use the GRANT command.


The following query uses a PURGE clause to delete all training and validation run data for the SpamFilter model:


The following query uses a DEFAULT clause to change the default trained model of SpamFilter to SpamFilter3

ALTER MODEL SpamFilter DEFAULT SpamFilter3

See Also

FeedbackOpens in a new tab