create database jintest;
show databases;
SELECT VERSION() ;
CREATE TABLE jintest.test1 (
tinyint1 TINYINT,
timestamp1 TIMESTAMP WITH LOCAL TIME ZONE,
ARRAY1 ARRAY<String>,
STRUCT1 STRUCT<id:int,grade:String>,
BIGINT1 BIGINT,
test3 VARCHAR(100),
UNIONTYPE1 UNIONTYPE<String,int>,
map1 map<String,int>
)
row format delimited fields terminated by '\t'
collection items terminated by ','
map keys terminated by ':'
lines terminated by '\n';
use jintest;
执行以下insert语句时报语法错误,无法向表中插入数据
INSERT INTO TABLE jintest.test1
(tinyint1, timestamp1, array1, struct1, bigint1, test3, uniontype1, map1)
VALUES(100, '2012-08-31 08:30:30', ('1','20','30'), (1,'AB'), 99999, 'test1', 'test1', map('math', 30));
需要修改成:
INSERT INTO TABLE jintest.test1
VALUES
(1, current_timestamp(), array('value1', 'value2'), named_struct('id',1, 'grade','AB'), 1000000000, 'example', create_union(0,'string',2),map('key',1));
Hive复杂数据类型往表中追加数据时需要加上指定关键字,不确定是否是特有特性?
需要查询知识库:Hive复杂类型与PostgreSQL复杂数据类型使用区别?
Hive模式:本地模式、远程模式和内置模式三种。
Hive配置与Clickhouse配置有些类似,默认为本地模式,需要开启metastore服务端口,否则无法进行远程访问。无论哪种模式如果需要获取Hive元数据,都需要与metastore服务进行交互。