CREATE [EXTERNAL] TABLE [IFNOTEXISTS] table_name [(col_name data_type [COMMENT col_comment], ...)] [COMMENT table_comment] [PARTITIONED BY (col_name data_type [COMMENT col_comment], ...)] [CLUSTERED BY (col_name, col_name, ...) [SORTED BY (col_name [ASC|DESC], ...)] INTO num_buckets BUCKETS] [ROWFORMAT row_format] [STOREDAS file_format] [LOCATION hdfs_path]
2.修改表结构
1 2 3 4
hive> ALTER TABLE events RENAME TO 3koobecaf; hive> ALTER TABLE pokes ADD COLUMNS (new_col INT); hive> ALTER TABLE invites ADD COLUMNS (new_col2 INT COMMENT 'a comment'); hive> ALTER TABLE invites REPLACE COLUMNS (foo INT, bar STRING, baz INT COMMENT 'baz replaces new_col2');
可以重命名表,添加列 重命名列或者修改列的数据结构,也可以用来删掉某一行
1
ALTERTABLE invites REPLACECOLUMNS (foo INTCOMMENT'only keep the first column');