1/export hive data
Many times, we execute the SELECT statement in hive to save the final result to a local file, to the HDFS system, or to a new table, hive provides convenient keywords to implement the functions described above.
1. Place the select result in a table (first, create a new table using create table)
Insert overwrite Table Test
Select uid, name from Test2;
2. Place the select result to the local file system.
Insert overwrite local directory '/tmp/reg_3' select a. * from events;
3. Place the select result in the HDFS File System
Insert overwrite directory '/tmp/hdfs_out' select a. * From invites a where a. DS = '<date> ';
2/hive Data Import
Load data [local] inpath '/data/userdata' [overwrite] into Table user;
# specify the path create external table page_view (viewtime int, userid bigint, page_url string, referrer_url string, IP string comment 'IP address of the user' when creating a table ', country string comment 'country of origination ') comment 'this is the staging page view table' row format delimited fields terminated by '44' lines terminated by '12' stored as textfilelocation '/user/data/staging/page_view '; # You can import data to a table after creating a table # Local path (stepping stone) load data local inpath '/tmp/date.txt' overwrite into Table page_view partition (Pt = '2017-06-08 ') # hadoop path load data inpath '/tmp/date.txt' overwrite into Table page_view partition (Pt = '2017-06-08 ') # The above overwrite key will cover the entire table, if you only want to append the data, remove overwrite. # Add a partition to the alter table tmp_xx add partition (Pt = '000000') location'/group/mywork/hive/XX/Pt = 100 '; # Of course, you can drag data from other tables directly to insert overwrite table tmp_t1 select * From tmp_t2;