表
1.创建表
create [external] table [if not exists] table_name (col_name data_type) [partitioned by col_name data_type] [clustered by col_name,col_name] [sorted by col_name] into num_buckets buckets] [row format] [stored as file_format]
[tblproperties]
[tblproperties] [location hdfs_path]
2.修改表
(1)重命名表 alter table student rename to student2;
(2)增加列信息:columns alter table student add columns(age int);
(3)替换列信息:columns,替换表中的所有字段 alter table student replace columns (score double);
(4)修改列信息:column --只修改列名 alter table student change column name student_name string; --只修改数据类型 alter table student change column name name int; --列名和数据类型都修改 alter table student change column name student_name int;
(5)删除列信息 alter table teacher drop column salary
3.删除表(只能删除内部表,不能删除外部表)
drop:同时删除表所有数据和表结构
truncat:删除表所有数据,不删除表结构
delete:删除表中的行数据
drop table student;
truncate table student;
delete from student where name='test'
posted on 2020-12-05 14:20 happygril3 阅读(59) 评论(0) 收藏 举报