code: func (d *ddl) AlterTableCharsetAndCollate(ctx sessionctx.Context, ident ast.Ident, toCharset, toCollate string) error {
  	// use the last one.
  	if toCharset == "" && toCollate == "" {
  		return ErrUnknownCharacterSet.GenWithStackByArgs(toCharset)
  	}
  
  	is := d.infoHandle.Get()
  	schema, ok := is.SchemaByName(ident.Schema)
  	if !ok {
  		return infoschema.ErrDatabaseNotExists.GenWithStackByArgs(ident.Schema)
  	}
  
  	tb, err := is.TableByName(ident.Schema, ident.Name)
  	if err != nil {
  		return errors.Trace(infoschema.ErrTableNotExists.GenWithStackByArgs(ident.Schema, ident.Name))
  	}
  
  	if toCharset == "" {
  		// charset does not change.
  		toCharset = tb.Meta().Charset
  	}
  
  	if toCollate == "" {
  		// get the default collation of the charset.
  		toCollate, err = charset.GetDefaultCollation(toCharset)
  		if err != nil {
  			return errors.Trace(err)
  		}
  	}
  	doNothing, err := checkAlterTableCharset(tb.Meta(), schema, toCharset, toCollate)
  	if err != nil {
  		return err
  	}
  	if doNothing {
  		return nil
  	}
  
  	job := &model.Job{
  		SchemaID:   schema.ID,
  		TableID:    tb.Meta().ID,
  		Type:       model.ActionModifyTableCharsetAndCollate,
  		BinlogInfo: &model.HistoryInfo{},
  		Args:       []interface{}{toCharset, toCollate},
  	}
  	err = d.doDDLJob(ctx, job)
  	err = d.callHookOnChanged(err)
  	return errors.Trace(err)
  }
docs: // AlterTableCharset changes the table charset and collate.