hive的基本操作

DDL(Data Definition Language) 用于数据库、表、视图等对象的创建与管理

DML(Data Manipulation Language) 用于数据加载、插入、更新、删除等操作

CREATE DATABASE [IF NOT EXISTS] database_name   [COMMENT database_comment]   [LOCATION hdfs_path]   [WITH DBPROPERTIES (property_name=property_value, ...)] 示例: create database db_hive; #创建基础数据库db_hive create database if not exists db_hive;#创建数据库进行校验 create database db_hive2 comment "store resource info";  #创建数据库db_hive1并添加描述 create database db_hive2 location "/db_hive2.db";

#创建一个数据库,指定数据库在HDFS上存放的位置 DQL(Data Select Language) 用于数据查询 UDF(User-Defined Functions ) 内置函数(Built-in Functions) UDAF(Built-in Aggregate Functions ) UDTF(Built-in Table-Generating Functions) 用户自定义函数,用于辅助数据查询

查看Hive中所有数据库 SHOW DATABASES [LIKE 'identifier_with_wildcards']; 查看数据库信息 DESCRIBE DATABASE [EXTENDED]database_name 示例:     show databases;  #查看/显示所有数据库     show databases like "db*"; #过滤显示查询的数据库     desc database db_hive; #显示数据库信息     desc database extended db_hive; #显示数据库详细信息,extended

创表

create table stu(id int) create external table if not exists stu1(id int) create table if not exists stu2(id int, name string) create table if not exists student( id int, name string) row format delimited fields terminated by '\t'; create table if not exists student2(id int, name string) row format delimited fields terminated by '\t' location '/user/hive/warehouse/student2';

创建分区表语法 CREATE TABLE table_name (column1 data_type, column2 data_type….)     PARTITIONED BY (partition1 data_type, partition2      data_type,….);    示例: create table dept_partition(deptno int, dname string, loc string) partitioned by (month string) row format delimited fields terminated by '\t';

  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值