Hive (HQL)基本用法

 

DDL(data defination language)

1,创建数据库

create database test_db;
use test_db;

说明,这个创建语法和mysql一样,创建一个数据库,名字是test_db,在fs中就表现是一个文件夹:/user/hive/warehouse/test_db.db

2,创建一个table,注意Table有点区别,先声明变量,后跟类型;

create table emp(empno int,ename string,job string,mgr int,hiredate string,salary double,comm double,deptno int)row format delimited fields terminated by '\t';

 这个在fs中就表现为一个文本文件,其中字段之间以‘/t’来分隔;

3.创建一个外表(external table),所谓外表就是类型与location对照表一样,但是不存储location中的原始数据,只存储路径;一旦外表删除了,location的原始数据不会变化;而内表就不一样,删除后,都会一起消失;

 

 

你可能感兴趣的:(大数据)