[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
启动hive之前应该先启动HDFS和Yarn。
start-dfs.sh
start-yarn.sh
两种启动方式
第一种:直接命令行输入
hive
第二种:
先启动服务端:hiveserver2
再启动客户端:beeline -u jdbc:hive2://master:10000 -n root
创建数据库(数据库名=haha)
create database haha;
查看库的信息:
desc database haha;
切换数据库:
use haha;
删除数据库:
drop database haha;
如果库中有表,需要强制删除:
drop database haha cascade;
查看hive中有哪些库:
show database;
hive中对表的操作:
内部表(t1)
创建内部表的时候,不用指定位置,会在默认的位置下,生成一个表目录。
create table t1(
id int,
name string,
city string
)
//将数据用,来进行分割
row format delimited
fields terminated by ",";
将本地数据加载到表中,是将本地文件发送表目录。
load data local inpath '本地文件表目录位置' into table t1;
将集群上的数据加载到表中,是将文件移动到表目录。
load data inpath '数据所在表目录位置' into table t1;
外部表(t2)
创建外部表的时候,需要指定表目录的位置。
create external table t2(
id int,
name string
)
row format delimited
fields terminated by ","
location '/t2';
load data local inpath '自己指定的表目录位置' into table t2;