Cheap VPS & Xen Server


Residential Proxy Network - Hourly & Monthly Packages

Hive DDL Commands


Create Database Statement

A database in Hive is a namespace or a collection of tables.

  1. hive> CREATE SCHEMA userdb;
  2. hive> SHOW DATABASES;

Drop database

  1. hive> DROP DATABASE IF EXISTS userdb;

Creating Hive Tables

Create a table called Sonoo with two columns, the first being an integer and the other a string.

  1. hive> CREATE TABLE Sonoo(foo INT, bar STRING);

Create a table called HIVE_TABLE with two columns and a partition column called ds. The partition column is a virtual column. It is not part of the data itself but is derived from the partition that a particular dataset is loaded into.By default, tables are assumed to be of text input format and the delimiters are assumed to be ^A(ctrl-a).

  1. hive> CREATE TABLE HIVE_TABLE (foo INT, bar STRING) PARTITIONED BY (ds STRING);

Browse the table

  1. hive>  Show tables;

Altering and Dropping Tables

  1. hive> ALTER TABLE Sonoo RENAME TO Kafka;
  2. hive> ALTER TABLE Kafka ADD COLUMNS (col INT);
  3. hive> ALTER TABLE HIVE_TABLE ADD COLUMNS (col1 INT COMMENT ‘a comment’);
  4. hive> ALTER TABLE HIVE_TABLE REPLACE COLUMNS (col2 INT, weight STRING, baz INT COMMENT ‘baz

Comments

comments