Flash Sale: Flat 70% + Addl. 25% Off on all Courses | Use Coupon DS25 in Checkout | Offer Expires In

  Enroll Now

Hive - Getting Started - Hands-on

We can access hive from the command line Let's connect to hive from the command line Login into CloudxLab Linux console Type hive and wait for hive prompt to appear this is called hive CLI or hive command-line interface. By default the database with the name default is the current database in the hive shell, to see the list of all databases type show databases;. As you can see there are 1557 databases in hive as of now, to see the list of all tables type show tables; .There are 887 tables in the default database, please create your database with the name same as your username. Make sure to create all the tables in your database instead of polluting the default database. Let's make a database with your username here our username is mayank8645, type create database ${env:USER}; to create database with your own name, the string ${env:USER} is replaced by your username automatically. Type describe database followed by your username or described database followed by the environment variable for user to see the metadata of the database. As you can see the database is located in the apps hive warehouse directory. To change the current database the use command is used. Type use followed by the database name or the variable that represents the user because the username is same as the database name for us and press enter, as you can see the current database had changed to your database. Now let's create a table with the name x inside your database. Type create table x press enter and wait till the table is created. The describe command displays metadata or information about a table such as names of columns and their data types. To see the metadata of the table x type describe x and press enter there is only one column a with int data type. To see the metadata and low label details type describe formatted x;. We can see the column names, their data types, database name, owner name, created time, hive warehouse location and the table type.

INSTRUCTIONS

Steps:

  • Login to the web console using your cloudxlab username and password
  • Launch Hive by typing hive in the web console
  • To see the list of all databases type command:

    show databases;
    
  • To see the list of all tables type command:

    show tables;
    
  • To create your own database run below commands. ${env:USER} gets replaced by your username automatically:

    create database ${env:USER};
    
  • To see the metadata of your database run below commands. ${env:USER} gets replaced by your username automatically:

    describe database ${env:USER};
    
  • To use your database run below commands. ${env:USER} gets replaced by your username automatically:

    use ${env:USER};
    
  • To create a table x in your database type command:

    create table x (a int);
    
  • To view the data of table x type command:

    select * from x;
    
  • To view the metadata(structure) of the table type command:

    describe x;
    
  • To see the metadata and low-level details type command:

    describe formatted x;
    

No hints are availble for this assesment

Answer is not availble for this assesment

Loading comments...