apache hive - Hive Create Database - hive tutorial - hadoop hive - hadoop hive - hiveql



apache hive related article tags - hive tutorial - hadoop hive - hadoop hive - hiveql - hive hadoop - learnhive - hive sql

What is Hive?

  • Hive is a database technology that can define databases and tables to analyze structured data.
  • The theme for structured data analysis is to store the data in a tabular manner, and pass queries to analyze it.
  • This hive tutorial explains how to create Hive database.
  • Hive contains a default database named default.
learn hive - hive tutorial - mysql vs hiveql -  hive programs -  hive examples

learn hive - hive tutorial - mysql vs hiveql - hive programs - hive examples

How to Create Database in Hive?

Create Database Statement

  • Create Database is a statement used to create a database in Hive.
  • A database in Hive is a namespace or a collection of tables.
learn hive - hive tutorial - hive create databse -  hive programs -  hive examples

learn hive - hive tutorial - hive create database - hive programs - hive examples

Syntax:

CREATE DATABASE|SCHEMA [IF NOT EXISTS] <database name>
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy hive tutorial team
  • Here, IF NOT EXISTS is an optional clause, which notifies the user that a database with the same name already exists.
  • We can use SCHEMA in place of DATABASE in this command.
  • The following query is executed to create a database named userdb:
hive> CREATE DATABASE [IF NOT EXISTS] userdb;
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy hive tutorial team
    or
hive> CREATE SCHEMA userdb;
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy hive tutorial team
  • The following query is used to verify a databases list:
hive> SHOW DATABASES;
default
userdb
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy hive tutorial team

 learn hive tutorial - hive create database - hive example

apache hive - learn hive - hive tutorial - hive create database - hive example

apache hive related article tags - hive tutorial - hadoop hive - hadoop hive - hiveql - hive hadoop - learnhive - hive sql

JDBC Program

  • The JDBC program is used to create a database and hence the program is given below.
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.DriverManager;
public class HiveCreateDb {
   private static String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver";
   public static void main(String[] args) throws SQLException {
      // Register driver and create driver instance
      Class.forName(driverName);
      // get connection
  Connection con = DriverManager.getConnection("jdbc:hive://localhost:10000/default", "", "");
      Statement stmt = con.createStatement();
      stmt.executeQuery("CREATE DATABASE userdb");
      System.out.println(“Database userdb created successfully.”);
      con.close();
   }
}
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy hive tutorial team
  • The commands are used to compile and execute this program.

Sample Code:

$ javac HiveCreateDb.java
$ java HiveCreateDb

Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy hive tutorial team
apache hive related article tags - hive tutorial - hadoop hive - hadoop hive - hiveql - hive hadoop - learnhive - hive sql

Output:

Database userdb created successfully.

Wikitechy Apache Hive tutorials provides you the base of all the following topics . Enjoy learning on big data , hadoop , data analytics , big data analytics , mapreduce , hadoop tutorial , what is hadoop , big data hadoop , apache hadoop , apache hive , hadoop wiki , hadoop jobs , hadoop training , hive tutorial , hadoop big data , hadoop architecture , hadoop certification , hadoop ecosystem , hadoop fs , apache pig , hadoop cluster , cloudera hadoop , hadoop download , hadoop mapreduce , hadoop workflow , hive data types , hadoop hive , pig hadoop , hadoop administration , hadoop installation , hive hadoop , learn hadoop , hadoop for dummies , hadoop commands , hive definition , hiveql , learnhive , hive sql , hive database , hive date functions , hive query , apache hive tutorial , hive apache , hive wiki , what is a hive , hive big data , programming hive , what is hive in hadoop , hive documentation , how does hive work

Related Searches to Hive Create Database