Linux中操作Hive常用命令

您所在的位置:网站首页 如何进入hive命令行 Linux中操作Hive常用命令

Linux中操作Hive常用命令

2024-05-26 20:03| 来源: 网络整理| 查看: 265

Linux中操作Hive常用命令 1、连接hive hive shell 2、输入hive的用户名和密码 username:hive password:hive 3、查询所有数据库 show databases; 4、查询所有数据表 show tables; 5、创建数据库 create database 数据库名称; 比如: create database test; 6、删除数据库 drop database 数据库名称;

比如:

drop database test;

注意:如果存在表会删除失败。 解决这个失败问题有2个方法: 第1个方法:先删除对应库的所有表,再删除库。 第2个方法:使用cascade关键字执行强制删库。drop database if exists 数据库名称 cascade;

7、创建表 -- 创建用户表 create table `test_user` ( `user_id` int comment '主键,用户id', `user_name` string comment '用户名称' ) row format delimited fields terminated by '\t' lines terminated by '\n' stored as textfile; 8、查看表结构 describe 数据表名称,简写:desc 数据表名称;

比如:

desc test2; 9、查看建表语句 show create table 数据表名称;

比如:

show create table test2; 10、删除表 drop table 数据表名称;

比如:

drop table test2; 11、仅删除表数据,保存表结构 truncate table 数据表名称;

比如:

truncate table test2; 12、删除分区 alter table 数据表名称 drop parttion (parttion_name ='分区名称');

比如:

alter table 数据表名称 drop parttion (parttion_name =''test2);


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3