概述
beeline可以用!connect jdbc:hive2://localhost:10000 用来连接hiveserver2启动的hive服务
建表操作
CREATE [EXTERNAL] TABLE [IF NOT EXISTS] table_name
[(col_name data_type [COMMENT col_comment], ...)]
[COMMENT table_comment]
[PARTITIONED BY (col_name data_type [COMMENT col_comment], ...)]
[CLUSTERED BY (col_name, col_name, ...)
[SORTED BY (col_name [ASC|DESC], ...)] INTO num_buckets BUCKETS]
[ROW FORMAT row_format]
[STORED AS file_format]
[LOCATION hdfs_path]
create external table t_sz_ex(id int,name string) row format delimited field terminated by 't' stored as textfile location '/sz_ex'; //建立一个外表
load data local inpath '/andy2.txt' into table t_sz_ex; //使用load名令将数据穿到指定位置
在hive里面可以直接用命令 dfs -ls 来查看Hadoop中的东西;
删数据的时候外部表的存储数据不会被删除,但是内部表会被删除
创建 分区表
0: jdbc:hive2://localhost:10000> create table t_sz_part(id int,name string) ng) row format delimited field terminated by 't' stored as textfile location '/sz_ex';
0: jdbc:hive2://localhost:10000> partitioned by (country string)
0: jdbc:hive2://localhost:10000> row format delimited
0: jdbc:hive2://localhost:10000> fields terminated by ',';
将数据导入到分区表中并且指定分区表
0: jdbc:hive2://localhost:10000> load data local inpath '/root/andy2.txt' into table t_sz_part partition(country=China);
最后
以上就是发嗲钢笔为你收集整理的Hive学习笔记的全部内容,希望文章能够帮你解决Hive学习笔记所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复