Altering Models

After you create a model, you can alter it in three ways: renaming the model, changing the owner, and changing the schema.

The following example shows how you can use ALTER_MODEL to rename a model:

  1. Find the model you want to alter.
  2. => SELECT * FROM V_CATALOG.MODELS WHERE model_name='mymodel';
    -[ RECORD 1 ]--+------------------------------------------
    model_id       | 45035996273816618
    model_name     | mymodel
    schema_id      | 45035996273704978
    schema_name    | public 
    owner_id       | 45035996273704962
    owner_name     | dbadmin 
    category       | VERTICA_MODELS
    model_type     | kmeans
    is_complete    | t
    create_time    | 2017-03-02 11:16:04.990626-05
    size           | 964
  3. Rename the model.
  4. => ALTER MODEL mymodel RENAME TO mykmeansmodel;
         ALTER MODEL
    
  5. Review V_CATALOG.MODELS to verify that the model name was changed.
  6. => SELECT * FROM V_CATALOG.MODELS WHERE model_name='mykmeansmodel';
    -[ RECORD 1 ]--+------------------------------------------
    model_id       | 45035996273816618
    model_name     | mykmeansmodel
    schema_id      | 45035996273704978
    schema_name    | public 
    owner_id       | 45035996273704962
    owner_name     | dbadmin 
    category       | VERTICA_MODELS
    model_type     | kmeans
    is_complete    | t
    create_time    | 2017-03-02 11:16:04.990626-05
    size           | 964
    

The following example shows how you can use ALTER_MODEL to change the model owner:

  1. Find the model you want to alter.
  2. => SELECT * FROM V_CATALOG.MODELS WHERE model_name='mykmeansmodel';
    -[ RECORD 1 ]--+------------------------------------------
    model_id       | 45035996273816618
    model_name     | mykmeansmodel
    schema_id      | 45035996273704978
    schema_name    | public 
    owner_id       | 45035996273704962
    owner_name     | dbadmin 
    category       | VERTICA_MODELS
    model_type     | kmeans
    is_complete    | t
    create_time    | 2017-03-02 11:16:04.990626-05
    size           | 964
  3. Change the model owner.
  4. => ALTER MODEL mykmeansmodel OWNER TO user1;
         ALTER MODEL
    
  5. Review V_CATALOG.MODELS to verify that the owner was changed.
  6. => SELECT * FROM V_CATALOG.MODELS WHERE model_name='mykmeansmodel';
    -[ RECORD 1 ]--+------------------------------------------
    model_id       | 45035996273816618
    model_name     | mykmeansmodel
    schema_id      | 45035996273704978
    schema_name    | public 
    owner_id       | 45035996273704962
    owner_name     | user1 
    category       | VERTICA_MODELS
    model_type     | kmeans
    is_complete    | t
    create_time    | 2017-03-02 11:16:04.990626-05
    size           | 964

The following example shows how you can use ALTER_MODEL to change the model schema:

  1. Find the model you want to alter.
  2. => SELECT * FROM V_CATALOG.MODELS WHERE model_name='mykmeansmodel';
    -[ RECORD 1 ]--+------------------------------------------
    model_id       | 45035996273816618
    model_name     | mykmeansmodel
    schema_id      | 45035996273704978
    schema_name    | public 
    owner_id       | 45035996273704962
    owner_name     | dbadmin 
    category       | VERTICA_MODELS
    model_type     | kmeans
    is_complete    | t
    create_time    | 2017-03-02 11:16:04.990626-05
    size           | 964
  3. Change the model schema.
  4. => ALTER MODEL mykmeansmodel SET SCHEMA test;
         ALTER MODEL
    
  5. Review V_CATALOG.MODELS to verify that the owner was changed.
  6. => SELECT * FROM V_CATALOG.MODELS WHERE model_name='mykmeansmodel';
    -[ RECORD 1 ]--+------------------------------------------
    model_id       | 45035996273816618
    model_name     | mykmeansmodel
    schema_id      | 45035996273704978
    schema_name    | test
    owner_id       | 45035996273704962
    owner_name     | dbadmin 
    category       | VERTICA_MODELS
    model_type     | kmeans
    is_complete    | t
    create_time    | 2017-03-02 11:16:04.990626-05
    size           | 964

Any user who creates a model can drop or alter his or her own model. If you are the user, you can drop or alter any model in the database.

See Also