hive建表語句

2021-10-10 18:30:16 字數 500 閱讀 5886

(1)只保留表的結構

create table table1 as select * from table2 where 2=3

(2)保留結構與資料

create table table1 as select * from table 2

(3)重新命名

create table table1(column1_rename, column2_rename) as select column1, column2 from table2

(4)查詢建標字段

show create table 表名

(5)建立分割槽表

create table `表名`( `欄位名` 字段型別, `欄位名` 字段型別) partitioned by (`分割槽欄位名` 分割槽字段型別);

(6)向分割槽表中插入資料

insert overwrite table 表名 partition(分割槽欄位名='分割槽字段值') select * from 表名

hive中建表語句

hive中一共有以下幾種建表方式 create table person id int,name string,hobbies array,address map row format delimited fields terminated by collection items terminate...

Hive建表語句解釋

drop table if exists tablename create external table tablename id string comment id name string comment 名字 price double comment comment 表名 partitioned...

批量生成hive建表語句

這裡以shell為例 bin bash db dim echo 匯出資料庫所有的表結構 hive e use db show tables root migration db tables.txt echo 迴圈遍歷表名 cat root migration db tables.txt while ...