hive中一些常用的sql語句


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM