Book Image

Hadoop MapReduce v2 Cookbook - Second Edition: RAW

Book Image

Hadoop MapReduce v2 Cookbook - Second Edition: RAW

Overview of this book

Table of Contents (19 chapters)
Hadoop MapReduce v2 Cookbook Second Edition
Credits
About the Author
Acknowledgments
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating databases and tables using Hive CLI


This recipe walks you through the commands to create Hive databases and tables using the Hive CLI. Hive tables are used to define structure (schema) and other metadata information such as the location and storage format on datasets stored in HDFS. These table definitions enable the data processing and analysis using the Hive query language. As we discussed in the introduction, Hive follows a "schema on read" approach, where it imposes this structure only when reading and processing the data.

Getting ready

For this recipe, you need a working Hive installation.

How to do it...

This section depicts how to create a Hive table and how to perform simple queries on the Hive tables:

  1. Start the Hive CLI by running the following command:

    $ hive
    
  2. Execute the following command to create and use a Hive database for the Book-Crossing dataset mentioned in the introduction:

    hive> CREATE DATABASE bookcrossing;
    hive> USE bookcrossing;
    
  3. Use the following command to...