hive> create table emp(empno int,ename string,job string,mgr int,hiredate string,sal double, comm double,deptno int) row format delimited fields terminated by ','; OK Time taken: 0.296 seconds
1 2 3 4 5 6 7 8 9 10 11
hive> desc emp; OK empno int ename string job string mgr int hiredatestring sal double commdouble deptno int Time taken: 0.407 seconds, Fetched: 8 row(s)
hive> load data local inpath '/opt/modules/hive-1.2.1/emp.txt' overwrite into table emp; Loading data to table default.emp Table default.emp stats: [numFiles=1, numRows=0, totalSize=126, rawDataSize=0] OK Time taken: 1.086 seconds
1 2 3 4
[root@node1 hive-1.2.1]# vi emp.txt [root@node1 hive-1.2.1]# cat emp.txt 7379,SMITH,CLIERk,7902,1980-12-17,800,20 7692,ALLEN,MANAGER,7982,1981-2-20,1600.00,300.00,30
1 2 3 4 5 6
hive> select * from emp; OK 7379SMITHCLIERk79021980-12-17800.020.0NULL 7692ALLENMANAGER79821981-2-201600.0300.030 NULLNULLNULLNULLNULLNULLNULLNULL Time taken: 0.14 seconds, Fetched: 3 row(s)
hive> create table emp_managed as select * from emp; Query ID = root_20160311082709_61648203-5965-4219-ae5e-4c5748966d1c Total jobs = 3 Launching Job 1 out of 3 Number of reduce tasks is setto0 since there's no reduce operator Starting Job = job_1457654255652_0001, Tracking URL = http://node5:8088/proxy/application_1457654255652_0001/ Kill Command = /opt/modules/hadoop-2.5.1/bin/hadoop job -kill job_1457654255652_0001 Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 0 2016-03-11 08:28:01,002 Stage-1 map = 0%, reduce = 0% 2016-03-11 08:28:29,956 Stage-1 map = 100%, reduce = 0%, Cumulative CPU 2.77 sec MapReduce Total cumulative CPU time: 2 seconds 770 msec Ended Job = job_1457654255652_0001 Stage-4 is selected by condition resolver. Stage-3 is filtered out by condition resolver. Stage-5 is filtered out by condition resolver. Moving data to: hdfs://matrix/usr/hive-1.2.1/warehouse/.hive-staging_hive_2016-03-11_08-27-09_038_7401835710561722844-1/-ext-10001 Moving data to: hdfs://matrix/usr/hive-1.2.1/warehouse/emp_managed Table default.emp_managed stats: [numFiles=1, numRows=3, totalSize=122, rawDataSize=119] MapReduce Jobs Launched: Stage-Stage-1: Map: 1 Cumulative CPU: 2.77 sec HDFS Read: 3586 HDFS Write: 198 SUCCESS Total MapReduce CPU Time Spent: 2 seconds 770 msec OK Time taken: 82.623 seconds
1
hive(hive)> select * from emp_managed;
1 2 3 4 5 6
hive> select * from emp_managed; OK 7379SMITHCLIERk79021980-12-17800.020.0NULL 7692ALLENMANAGER79821981-2-201600.0300.030 NULLNULLNULLNULLNULLNULLNULLNULL Time taken: 0.172 seconds, Fetched: 3 row(s)