1.连接hive
beeline -u jdbc:hive2://127.0.0.1:10000
2.查询数据库、数据库中的表名
show databases;
show databases like 'superhero*';
show tables;
查看表结构:desc superhero_bi.raw_spendlog;
3.使用数据库
use superhero_bi;
4.创建数据库
create database test;
5.删除表中的数据
truncate table raw_gem;
6.修改字段名、字段类型
ALTER TABLE superhero_vt.raw_spendlog CHANGE user_id uid string;
7.强制删除数据库(hive默认不允许删除包含表的数据库,否则会报错:Database superhero_tr is not empty)
DROP DATABASE IF EXISTS superhero_tr CASCADE;
8.创建与同样的分区表(但不能copy对应分区的数据)
create table table1 like table2;
9.创建表结构、类型相同的表(可以copy数据,但是不能copy对应的分区)
create table table1 as select * from table2;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29667072/viewspace-2120661/
,如需转载,请注明出处,否则将追究法律责任。