建表:内部表、外部表、分区表、桶表
内部表:
create table if not exists student(
id int,name string,age int,sex string
)row format delimited
fields terminated by "\t";
查看创建表的信息
show create table student;
查看表结构(列)信息
desc student;
导入数据方法一:
load data local inpath '/home/tg/datas/students' overwrite into table student;
外部表:
create external table if not exists stutest(
id int,name string,age int,sex string
)row format delimited
fields terminated by "\t"
location '/input/stutest';
导入数据方法二:
hadoop fs -put students /input/stutest/
create table student
as
select * from stus;
分区表:
单分区:
create table if not exists stutest(
id int,name string,age int,sex string
)partitioned by (grade string)
内部表:
create table if not exists student(
id int,name string,age int,sex string
)row format delimited
fields terminated by "\t";
查看创建表的信息
show create table student;
查看表结构(列)信息
desc student;
导入数据方法一:
load data local inpath '/home/tg/datas/students' overwrite into table student;
外部表:
create external table if not exists stutest(
id int,name string,age int,sex string
)row format delimited
fields terminated by "\t"
location '/input/stutest';
导入数据方法二:
hadoop fs -put students /input/stutest/
create table student
as
select * from stus;
分区表:
单分区:
create table if not exists stutest(
id int,name string,age int,sex string
)partitioned by (grade string)