Create Sample Hive Table

To create sample hive table we can use below command in hive shell

CREATE TABLE IF NOT EXISTS test_table  (col1 int COMMENT 'Integer Column',  col2 string COMMENT 'String Column'  )  COMMENT 'This is test table'  ROW FORMAT DELIMITED  FIELDS TERMINATED BY ','  STORED AS TEXTFILE;

Once hive table is created we can use below insert command

insert into test_table values(1,'aaa');

This will insert one record in hive table to add one more record we can run insert command again

insert into test_table values(2,'bbb');

To see if our data is inserted in the table we can use select command

hive> select * from test_table;
 OK
 1    aaa
 2    bbb
 Time taken: 0.119 seconds, Fetched: 2 row(s)

Creating table for performance testing

create database perf;
use perf;
CREATE TABLE t1 (productID int, code string,name string,quantity int, price float) STORED AS parquet ;
show create table t1;

Leave a Comment