我们安装完Hive,配置好hive-site.xml文件,其中我把hive在hdfs路径设置为hive110/warehouse
启动hadoop
hdfs dfs -chmod -R 777 /hive110给所有组加最高权限,方便以后操作
登录hive,这里我直接使用本地登录,也就不适用hiveserver2了
Hive——分区的详细图文介绍,绝对看懂!
增加/修改/替换列信息
更新列
alter table table_name change [column] col_old_name col_new_name
column_type [first|after column_name]
比如我把dept表的loc列名改为money 并指明是String类型
hive (stu)> alter table dept change column loc money string;
增加和替换列
alter table table_name add|replace columns (col_name data_type, …)
注:add 是代表新增一字段,字段位置在所有列后面(partition 列前),replace 则是
表示替换表中所有字段。
比如我添加add和phone列
replace 表示替换表中所有字段。这里把所有列都换成最后add和phone这两个列
三、删除表
hive (default)> drop table dept;
虽然删除了表,但是hdfs的数据还在
如果我这时再创一张相同的表,我们不用导入数据就可以查到内容
四、查表
查看stu库下有几个表
use stu;
show tables;