下面来继续分享并记录hive相关:
1、创建表
1)创建表有两个字段
hive> CREATE TABLE pokes(apple INT, banana STRING);
2)创建表带有分区
hive> CREATE TABLE fruits (apple INT, banana STRING) PARTITIONED BY (ds STRING);
2、查看表
查看所有表的列表:
hive> SHOW TABLES;
通过正则表达式查看表:
hive> SHOW TABLES '.*S';
查看表字段:
hive> DESCRIBE fruits ;
3、更改或删除表
1)修改表名
hive> ALTER TABLE events RENAME TO events_test;
2)添加字段
hive> ALTER TABLE pokes ADD COLUMNS (new_col INT);
hive> ALTER TABLE fruits ADD COLUMNS (new_col2 INT COMMENT 'hello world');
3)修改字段
hive> ALTER TABLE fruits REPLACE COLUMNS(apple INT, banana STRING, pear INT COMMENT 'replcate col');
4)删除表
hive> DROP TABLE pokes;