Hive command Line Common commands
Loading data
Load data local inpath '/home/ivr_csr_menu_map.txt ' into table ivr_csr_menu_map;
Partitioned by:
Load data local inpath '/home/lftest/lf1.txt ' overwrite into table lf_test partition (dt=20150927);
Add overwrite will overwrite the original data (if any) if not added, and the original data, a copy file will be generated
Load data local inpath '/home/lftest/lf1.txt ' overwrite into table lf_test partition (dt=20150927);
DFS can be used within the Hive command line to perform some Hadoop commands
View Catalog
Dfs-ls/apps/hive/warehouse/lf_test;
View File Contents
Hive> Dfs-text/apps/hive/warehouse/lf_test/dt=20150928/lf.txt;
deleting files
Dfs-rm/apps/hive/warehouse/lf_test/dt=20150927/lf1_copy_2.txt;
Delete Directory
Dfs-rm-r/apps/hive/warehouse/lf_test;
Show Table Partitioning
Show Partitions lf_test;
adding partitions
ALTER TABLE Lf_test add partition (dt=20150928);
Delete Partition
ALTER TABLE Lf_test drop partition (dt=20150928);
Show detailed table structure: (includes information such as fields, partitions, etc.)
Desc formatted ivr_calldata;
Display the Build Table statement
Show CREATE TABLE sas_ambs;
To delete a table:
drop table lf_test;
Renaming a table
ALTER TABLE employee RENAME to EMP;
CREATE TABLE (internal table):
Hive> CREATE TABLE lf_test (ID int,name string,age Int,tel string)
> Partitioned by (DT string)
> ROW FORMAT Delimited
> TERMINATED by ' | '
> STORED as Textfile;
External table
Create EXTERNAL Table Ivr_csr_menu_map (
csr_reason_id String,
Csr_reason_name String,
ivr_node_id String,
Ivr_node_name string)
ROW FORMAT Delimited
Fields TERMINATED by ' | '
STORED as Textfile
Location '/spdbccc/data/dest/ivr/ivr_csr_menu_map/'; Specifies the path to the data file, at which time the folder is not generated under warehouse
Hive Shell Common Commands