Hive - Schematool

Card Puncher Data Processing


Schematool is a offline command line tool to manage the metastore.

This tool can be used to initialize the metastore schema for the current Hive version.



  • HOME/bin
  • Hortonworks (/usr/hdp/current/hive-client/bin/hive or /usr/hdp/
usage: schemaTool
 -dbOpts <databaseOpts>             Backend DB specific options
 -dbType <databaseType>             Metastore database type
 -dryRun                            list SQL scripts (no execute)
 -help                              print this message
 -info                              Show config and schema details
 -initSchema                        Schema initialization
 -initSchemaTo <initTo>             Schema initialization to a version
 -passWord <password>               Override config file password
 -servers <serverList>              a comma-separated list of servers used
                                    in location validation
 -upgradeSchema                     Schema upgrade
 -upgradeSchemaFrom <upgradeFrom>   Schema upgrade from a version
 -userName <user>                   Override config file user name
 -validate                          Validate the database
 -verbose                           only print SQL statements



      JDBC connect string for a JDBC metastore.
      To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL.
      For example, jdbc:postgresql://myhost/db?ssl=true for postgres database.
    <description>Driver class name for a JDBC metastore</description>
    <description>password to use against metastore database</description>
    <description>Username to use against metastore database</description>


./schematool -dbType mssql -info 
Metastore connection URL:        jdbc:sqlserver://;database=clus01;encrypt=true;trustServerCertificate=true;create=false;loginTimeout=300
Metastore Connection Driver :
Metastore connection User:       hi_hive
Hive distribution version:       1.2.1000
Metastore schema version:        2.3.0
schemaTool completed


./schematool -dbType mssql -initSchema
Metastore connection URL:        jdbc:sqlserver://;database=clus01
Metastore Connection Driver :
Metastore connection User:       userName
Starting metastore schema initialization to 2.3.0
Initialization script hive-schema-2.3.0.mssql.sql
Initialization script completed
schemaTool completed

Table list

for SQL Server:

SELECT AS tbl_name, AS sch_name
FROM sys.tables tbl,
  sys.schemas sch
  tbl.schema_id = sch.schema_id AND = 'hi_hive'

Local Installation on Windows with Docker

Console used: cmder.

  • Download and unzip Hadoop distribution
  • Download and unzip Hive Distribution
  • File Structure Example

  • Start a docker image with Java
SOURCE_MOUNT_POINT=$(cygpath -u $(readlink -f .))
docker run \
  -it \
  --rm \
  --mount type=bind,source=/$SOURCE_MOUNT_POINT,target=/wd \
  • Then
export HADOOP_HOME=/wd/hadoop-2.8.1/
cd /wd/apache-hive-2.3.2-bin/bin


Failed to load driver

org.apache.hadoop.hive.metastore.HiveMetaException: Failed to load driver
Underlying cause: java.lang.ClassNotFoundException :

It may be a connection problem. Verify your connection informations.

Documentation / Reference

Discover More
Hive Metastore Er Diagram
Hive - Metastore

All the metadata for Hive tables and partitions are accessed through the Hive Metastore. Derby is the default database for the Hive metastore. See ...

Share this page:
Follow us:
Task Runner