欢迎投稿

今日深度:

hive的命令,

hive的命令,


查看hive内置函数

 show functions;

清除屏幕

ctrl+L 或  !clear

查看表

show tables;

查看表结构

desc tableName;

查看HDFS上文件

hive> dfs -ls /home/hive/;
Found 1 items
drwxrwxrwx   - hive hdfs          0 2017-11-27 06:41 /home/hive/external
hive> 

执行操作系统的命令

!command
如:
hive> !ls;
derby.log
hive>

插入一条数据

查询数据

hive> select * from test;
OK
1       chb
Time taken: 0.463 seconds, Fetched: 1 row(s)
hive> 

字段修改与添加

修改列的名称、类型、位置、注释
hive>ALTER TABLE t3 CHANGE COLUMN old_name new_name String COMMENT '...' AFTER column2;
##必须有跟着字段类型, 即使类型没有改变

添加字段
ALTER TABLE t2_tmp ADD COLUMNS(c int , d string);

表的复制

复制表接结构  注意是表结构, 如果原表是分区表, 使用like可以复制表结构, 而使用as 只能复制数据, 而且会添加两个字段 
create table t3 like  select * from t2;   
复制表结构以及数据  
create table t3_1 as select * from t2;  
hive> select * from t2;  
OK  
1       a  
1       a  
1       b  
1       b  
Time taken: 0.411 seconds, Fetched: 4 row(s)  
hive> select * from t3;  
OK  
Time taken: 0.387 seconds  
hive> select * from t3_1;  
OK  
1       a  
1       b  
1       a  
1       b  
Time taken: 0.419 seconds, Fetched: 4 row(s)  
hive>  

www.htsjk.Com true http://www.htsjk.com/hive/41607.html NewsArticle hive的命令, 查看hive内置函数 show functions; 清除屏幕 ctrl+L 或 ! clear 查看表 show tables; 查看表结构 desc tableName; 查看HDFS上文件 hive dfs -ls /home/hive/;Found 1 itemsdrwxrwxrwx - hive hdfs 0 2017 - 11...
相关文章
    暂无相关文章
评论暂时关闭