@Override
  protected void doAlteration(Database database, Map<String, String> params) throws HiveException {
    try {
      String newManagedLocation = Utilities.getQualifiedPath(context.getConf(), new Path(desc.getManagedLocation()));

      if (database.getLocationUri().equalsIgnoreCase(newManagedLocation)) {
        throw new HiveException("Managed and external locations for database cannot be the same");
      }

      URI locationURI = new URI(newManagedLocation);
      if (!locationURI.isAbsolute() || StringUtils.isBlank(locationURI.getScheme())) {
        throw new HiveException(ErrorMsg.BAD_LOCATION_VALUE, newManagedLocation);
      }

      if (newManagedLocation.equals(database.getManagedLocationUri())) {
        LOG.info("AlterDatabase skipped. No change in location.");
      } else {
        database.setManagedLocationUri(newManagedLocation);
      }
    } catch (URISyntaxException e) {
      throw new HiveException(e);
    }
  }
Operation process of altering a database's managed location.
ql/src/java/org/apache/hadoop/hive/ql/ddl/database/alter/location/AlterDatabaseSetManagedLocationOperation.java