In this article, learn how to create a table in Hive and load data. We will also show you crucial HiveQL commands to display data.
A table in Hive is a set of data that uses a schema to sort the data by given identifiers. The general syntax for creating a table in Hive is:
[sourcecode lang="sql"]CREATE [EXTERNAL] TABLE [IF NOT EXISTS] [db_name.]table_name
(col_name data_type [COMMENT 'col_comment'],, ...)
[COMMENT 'table_comment']
[ROW FORMAT row_format]
[FIELDS TERMINATED BY char]
[STORED AS file_format];
[/sourcecode]
- Create database in Apache Hive,
create database example;
- Verify your database, is it already created?
show example;
- Open your database
use example;
- Create the 'products' table:
create table products (id int, name string, sku string, price string, quantity int)
0 comments:
Post a Comment