欢迎投稿

今日深度:

Hive中的表操作,Hive表操作

Hive中的表操作,Hive表操作


Hive中的表操作

Hive中的表的基本操作。如下。

首先创建一个雇员表和部门表

  • 雇员表
    create table emp(
    empno int,
    ename string,
    job string,
    mgr int,
    hiredate string,
    sal double,
    comm double,
    deptno int
    )
    row format delimited fields terminated by '\t';
    '\t':表示制表符(tab)

  • 部门表
    create table dept(
    deptno int,
    dname string,
    loc string
    )
    row format delimited fields terminated by '\t';


    deptAndEmp

    deptAndEmp

  • 加载数据到表
    说明:加载的txt文本数据的字符格式必须是UTF-8格式
    加载数据命令:
    load data local inpath '/opt/datas/emp.txt' overwrite into table emp;
    load data local inpath '/opt/datas/dept.txt' overwrite into table dept;

1240
  • 根据子查询创建表 create table if not exists default.dept_cats as select * from dept;
    1240

表操作

  • 删除表中的数据
    truncate table dept_cats ;


    1240
  • 创建表 1、创建一个dept_like表 create table if not exists default.dept_like like default.dept;
    1240

2、把dept_like表重新命名为dept_like_rename alter table dept_like rename to dept_like_rename; rename

rename

  • 删除一张表
    命令:drop table if exitis dept_like_rename;


    1240

www.htsjk.Com true http://www.htsjk.com/hive/11029.html NewsArticle Hive中的表操作,Hive表操作 Hive中的表操作 Hive中的表的基本操作。如下。 首先创建一个雇员表和部门表 雇员表 create table emp( empno int, ename string, job string, mgr int, hiredate string, sal double,...
评论暂时关闭