create database shizhan03.db;
create table t_sz;
创建一个hivedemo的txt
将txt文件上传到hadoop的hdfs上。
truncate table t_sz;
drop table t_sz;
create table t_sz(id int,name string)
row format delimited
fields terminated by ",";
select * from t_sz;
select id,name from t_sz where id>3;
查看hadoop的UI界面可以看到已经创建成功了。
当执行create database shizhan03.db;时hdfs中自动创建了/user/hive/warehouse/shizhan03.db
当执行create table t_sz;时hdfs自动创建了t_sz目录
使用hive的thrift服务:
启动bin下的hiverserver2之后可以把hive做成服务器端,这样就可以提供给多个客户端连接
hive相比于传统mysql数据库来说就是可以有多个客户端来连接。
这就是hive的thrift服务,需要同样支持thrift协议的客户端去连接,比如bin下的beeline
!connect jdbc:hive:localhost:10000
提示输入要连接的用户名和密码,使用登录hadoop的用户名和密码 如s0,没有密码。