1.建表
CREATE TABLE IF NOT EXISTS student(
time varchar(64) ,
num int ,
age int
)
PARTITIONED BY ( score int)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
STORED AS PARQUET tblproperties("parquet.compress"="SNAPPY");
2.加載數據
load data local inpath '/opt/datas/student.txt' overwrite into table student ;
3.刪除表
DROP table database_name.table_name;
4.修改表的字段名
ALTER TABLE student CHANGE age height int
5.截斷表(即清空表的數據)
truncate student
6.一些查詢語句
1.select * from student order by age ;
2.select * from student sort by age ;
3.select * from student group by age;
4.select * from student group by age having num > 100;
5.select * from student where age>13;
6.select s1.name, s1.age, s2.name, s2.money from student1 s1 join student2 s2 on s1.name=s2.name ;
7.select * from student1 order by age limit 3 union select * from student2 order by age limit 3;
8.select distinct age from student
