1.建表
语法格式:create table student(freg int, word string) row format delimited fields terminated by'\t' stored as textfile;
FIELDS TERMINATED BY ',' 字段分隔符
LINES TERMINATED BY '\n' 行分隔符
STORED AS TEXTFILE; 作为文本存储
2.修改表语句
添加一列整数类型的列:
ALTER TABLE sutdent ADD COLUMNS (new_col int);
更改表名:
ALTER TABLE student RENAME TO test;
3.表分区操作语句
将/input/hive/partitions/file1 加载到logs 表的分区2012-11-20 的子分区China 内:
LOAD DATA LOCAL INPATH ‘input/hive/partitions/file1′
INTO TABLE logs(www.daowen.com)
PARTITION(date='2012-11-20',country='China');
4.删除表语句
删除表test:
DROP TABLE test;
5.创建和删除视图
创建一个视图:
CREATE VIEW[IF NOT EXISTS] student_view (id, name_length) as
SELECT t id, length(name) FROM student;
删除视图:
DROP VIEW IF EXISTS student_view;
6.查看数据表的描述
DESCRIBE test;
免责声明:以上内容源自网络,版权归原作者所有,如有侵犯您的原创版权请告知,我们将尽快删除相关内容。