drop table cshive;
CREATE TABLE IF NOT EXISTS `cshive` (
`int_test` INT primary key not enforced,
`smallint_test` SMALLINT,
`varchar_test` VARCHAR(100),
`array_test` ARRAY < STRING >,
`map_test` MAP < STRING,STRING >,
`struct_test` STRUCT < math :INT, english :INT >,
`bigint_test` BIGINT,
`binary_test` BINARY,
`boolean_test` BOOLEAN,
`char_test` CHAR(100),
`date_test` DATE,
`decimal_test` DECIMAL(18, 2),
`double_test` DOUBLE,
`float_test` FLOAT,
`string_test` STRING,
`timestamp_test` TIMESTAMP
) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' COLLECTION ITEMS TERMINATED BY '|' MAP KEYS TERMINATED BY '#' STORED AS TEXTFILE;
INSERT INTO TABLE cshive
VALUES (
22, -- int
12, -- smallint
'example_varchar',
array('element1', 'element2'), -- array<string>
map('key1','value1', 'key2','value2'), -- map<string,string>,注意'#'是MAP KEYS TERMINATED BY指定的分隔符
named_struct('math', 100, 'english', 90), -- struct<math:int,english:int>
1234567890123456789, -- bigint
CAST('This is a placeholder for binary data' AS BINARY), -- binary,这里只是一个字符串示例,实际应使用二进制数据
true, -- boolean
'example_char', -- char(100)
'2023-10-23', -- date
1234567890.12, -- decimal(18,2)
123.456, -- double
12.34, -- float
'example_string', -- string
'2024-07-03 11:17:46.123456' -- timestamp
),(
23, -- int
12, -- smallint
'example_varchar',
array('element1', 'element2'), -- array<string>
map('key1','value1', 'key2','value2'), -- map<string,string>,注意'#'是MAP KEYS TERMINATED BY指定的分隔符
named_struct('math', 100, 'english', 90), -- struct<math:int,english:int>
1234567890123456789, -- bigint
CAST('This is a placeholder for binary data' AS BINARY), -- binary,这里只是一个字符串示例,实际应使用二进制数据
true, -- boolean
'example_char', -- char(100)
'2023-10-23', -- date
1234567890.12, -- decimal(18,2)
123.456, -- double
12.34, -- float
'example_string', -- string
'2024-07-03 11:17:46.123321' -- timestamp
);
hive字段类型建表插入数据
于 2024-05-31 11:32:31 首次发布