Monday, September 9, 2013

Partitions

Partition : means to categorize the data in a table.
Ø Whenever we request a piece of data we use Partitions  by default  it is a Non-Partitioned Table.
Ø
Types:  1. Partitioned
              2. Non – Partitioned  (by Default)
EX: Non-Partitioned:
 Syntax: create table <table name>(col1 data type,col2 data type, …………) row format  delimited
                                  fields  terminated  by  ‘,’
Loading:  load data local inpath ‘<local file name>’ into table  <table name>;
EX: Partitioned:


Syntax  EX:   hive> create table sales_day(prid int,prname string,quantity int,price double,branch string) partitioned by (day int,month int,year int) row format delimited fields terminated by ',';                          


hive> load data local inpath 'sales' into table sales_day partition(day=12,month=2,year=2013);

Hive> load data local inpath ‘sales2’ into table sales_day partition(day=13,month=2,year=2013);

Hive> select * from sales_day;

Note : 
ØIn hive Partitioned  are logical  in RDBMS the partitions are Physical;

ØWe use the technique of partitions  to  manage  incremental   loads;

No comments:

Post a Comment