hive 包含所有欄位的建表語句

2022-09-12 03:45:06 字數 2960 閱讀 2806

drop table if exists sk_test_create_hive_create_all_fields;

create table if not exists sk_test_create_hive_create_all_fields(

`user_id` bigint comment '產品id',

`user_name` string comment '登入名',

`status` tinyint comment '使用者狀態 0正常 1凍結',

`user_name_init` int comment '使用者名稱是否已修改 0 未修改 1 已修改',

`ctime` timestamp comment '建立時間',

`invalid` smallint comment 'y:無效,n:有效',

`last_login_time` date comment '最後登入時間',

`size` float comment 'size',

`dou` double,

`dec` decimal,

`success` boolean,

`file` binary,

`arr` array,

`map` map,

`struct` struct

) comment '' partitioned by (ds string comment '') stored as orc;

drop table if exists sk_test_create_hive_all_fields;

create table if not exists sk_test_create_hive_all_fields(

`user_id` bigint comment '產品id',

`user_name` string comment '登入名',

`status` tinyint comment '使用者狀態 0正常 1凍結',

`user_name_init` int comment '使用者名稱是否已修改 0 未修改 1 已修改',

`ctime` timestamp comment '建立時間',

`invalid` smallint comment 'y:無效,n:有效',

`last_login_time` date comment '最後登入時間',

`size` float comment 'size',

`dou` double,

`dec` decimal,

`success` boolean,

`file` binary,

`arr` array < string >,

`map` map < string,int >

) comment '' partitioned by (ds string comment '') row format delimited

fields terminated by "," collection items terminated by ":" stored as orc;

insert into

sk_test_create_hive_all_fields partition(ds = '20200601')

values(1,

'xiaodou',

'1',

1,unix_timestamp(),

'y',

to_date('2011-12-08 10:03:01'),

'1.933435',

'2.103283928',

'18274514398103941',

'1',

null,

array('beijing','shanghai','guangzhou'),

map('bigdata',100)

);drop table if exists sk_test_datax_support_hive2mysql;

create table if not exists sk_test_datax_support_hive2mysql(

`user_id` bigint comment '產品id',

`user_name` string comment '登入名',

`status` tinyint comment '使用者狀態 0正常 1凍結',

`user_name_init` int comment '使用者名稱是否已修改 0 未修改 1 已修改',

`ctime` timestamp comment '建立時間',

`invalid` smallint comment 'y:無效,n:有效',

`last_login_time` date comment '最後登入時間',

`size` float comment 'size',

`dou` double,

`dec` decimal(30,10),

`success` boolean,

`file` binary

) comment '' partitioned by (ds string comment '') row format delimited

fields terminated by "," stored as orc;

insert into

sk_test_datax_support_hive2mysql partition(ds = '20200601')

values(1,

'xiaodou',

'1',

1,unix_timestamp(),

'1',

to_date('2011-12-08 10:03:01'),

'1.933435',

'2.103283928',

'1827451439810',

'1',

unbase64('hello binary !!!')

);

hive建表語句

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 ...

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...