HIVE partition by enabling the Partitionby implementation when the table is created, the dimension used to partition is not a column of the actual data, and the partition-specific flag is given when the content is inserted. When you want to query the contents of a partition, you can use the where statement, which resembles where Tablename.partition_key >a to implement. Create a table with partitions. Command prototypes:CREATE TABLE Page_view (viewtime INT, UserID BIGINT, page_urlstring, referrer_url STRING, ip stringcomment ' IP Addr ESS of the User ') COMMENT ' This isthe Page view table ' partitioned by (dtstring, Country STRING) Clusteredby (userid) SORTED by (Viewtime) into + bucketsrow formatdelimited fieldsterminated by ' \001 ' COLLECTION itemsterminated by ' \002 ' MAP keysterminate D by ' \003 ' STORED assequencefile;
Eg:Build Table:CREATE TABLE c02_clickstat_fatdt1(YYYYMMDD string,ID INT,IP String,Country String,cookie_id String,page_id String,clickstat_url_id int,query_string String,Refer string) partitioned by (DT STRING)row format delimited fields terminated by ' \005 ' stored astextfile;Loading Data:LOAD DATA inpath '/user/admin/sqlldrdat/cnclickstat/20101101/19/clickstat_gp_fatdt0/0 ' Overwriteinto TABLE c02_ CLICKSTAT_FATDT1PARTITION (dt= ' 20101101 ');Access a partitionSELECT Count (*)FROMC02_CLICKSTAT_FATDT1 aWHERE a.dt >= ' 20101101 ' and A.dt < ' 20101102 ';
HIVE create partition