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

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

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

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