1.创建数据库
create database test; error: database already exists
2.显示所有数据库
show databases;
3.删除数据库
drop database test;
4.创建表
create table stu(字段名 字段类型,.......) row format delimited fields terminated by '\t';
创建外部表
create external table stu(字段名 字段类型,.......) row format delimited fields terminated by '\t' location '/......';
创建分区表
create table stu(字段名 字段类型,.......) row format delimited fields terminated by '\t' parttioned by (分区字段 字段类型..);
5.删除表
drop table stu;
6.查看表结构
desc stu;
7.加载数据
load data inpath '/.....' into table stu; hdfs路径
load data local inpath '/...' into table stu; 本地linux路径
8.增加删除分区
alter table test add partition (x=x1,y=y2) location ‘/user/test/x1/y1’;
修改分区
alter table test add partition (x=x1,y=y2) set location ‘/user/test/x1/y1’;
删除分区
alter table test drop partition (x=x1,y=y2)
9.查询
查询所有
select * from stu;
查询单个
select ziduanmingh from stu;
limit 条数
select * from stu limit 10;