创建表:
hive> CREATE TABLE pokes (foo INT,bar STRING);
hive> CREATE TABLE invites (foo INT,bar STRING) PARTITIONED BY (ds STRING);
查看表: SHOW TABLES;
查看列: DESCRIBE invites;
修改表:
hive> ALTER TABLE pokes ADD COLUMNS (new_col INT);
hive> ALTER TABLE invites ADD COLUMNS (new_col2 INT COMMENT 'acomment');
hive> ALTER TABLE invites REPLACE COLUMNS (foo INT, bar STRING, baz INTCOMMENT 'baz replaces new_col2');
Note that REPLACE COLUMNSreplaces all existing columns and only changes the table’s schema, not thedata. The table must use a native SerDe. REPLACE COLUMNS can also be used todrop columns from the table’s schema:
hive>ALTER TABLE invites REPLACE COLUMNS (foo INT COMMENT 'only keep the firstcolumn');
Dropping tables:
hive>DROP TABLE pokes;
create table wyp
(id int, name string,age int, tel string) ROWFORMAT DELIMITED FIELDS TERMINATED BY '\t' STORED AS TEXTFILE;
vi wyp.txt
1 wyp 25 13188888888888
2 test 30 13888888888888
3 zs 34 899314121
load data localinpath 'wyp.txt' into table wyp;