public String lockTable(String txnLockTable, boolean shared) throws MetaException {
    switch (dbType) {
    case MYSQL:
      // For Mysql we do not use lock table statement for two reasons
      // It is not released automatically on commit/rollback
      // It requires to lock every table that will be used by the statement
      // https://dev.mysql.com/doc/refman/8.0/en/lock-tables.html
      return "SELECT  \"TXN_LOCK\" FROM \"" + txnLockTable + "\" " + (shared ? "LOCK IN SHARE MODE" : "FOR UPDATE");
    case POSTGRES:
      // https://www.postgresql.org/docs/9.4/sql-lock.html
    case DERBY:
      // https://db.apache.org/derby/docs/10.4/ref/rrefsqlj40506.html
    case ORACLE:
      // https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_9015.htm
    case CUSTOM: // ANSI SQL
      return "LOCK TABLE \"" + txnLockTable + "\" IN " + (shared ? "SHARE" : "EXCLUSIVE") + " MODE";
    case SQLSERVER:
      // https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-table?view=sql-server-ver15
      return "SELECT * FROM \"" + txnLockTable + "\" WITH (" + (shared ? "TABLOCK" : "TABLOCKX") + ", HOLDLOCK)";
    default:
      String msg = "Unrecognized database product name <" + dbType + ">";
      LOG.error(msg);
      throw new MetaException(msg);
    }
  }
Returns the SQL query to lock the given table name in either shared/exclusive mode
@param txnLockTable
@param shared
@return
@throws MetaException
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/DatabaseProduct.java