使用Postgres 数据库作为 Catalog
CREATE CATALOG mypg WITH(
'type' = 'jdbc',
'default-database' = 'flink_catalog',
'username' = 'postgres',
'password' = 'postgres',
'base-url' = 'jdbc:postgresql://192.168.1.4:5432'
);
USE CATALOG mypg;
CREATE TABLE MyUserTable (
order_id BIGINT,
customer_name STRING,
PRIMARY KEY (order_id) NOT ENFORCED
) WITH (
'connector' = 'jdbc',
'url' = 'jdbc:mysql://192.168.1.4:3306/mydb',
'table-name' = 'orders',
'username' = 'mysqluser',
'password' = 'mysqlpw'
);
CREATE CATALOG myhive WITH (
'type' = 'hive',
'default-database' = 'hive',
'hive-conf-dir' = '/usr/local/hive/conf'
);
-- set the HiveCatalog as the current catalog of the session
USE CATALOG myhive;
CREATE TABLE mysql_orders (
order_id INT,
customer_name String,
product_id INT
) WITH (
'connector' = 'jdbc',
'url' = 'jdbc:mysql://192.168.1.4:3306/mydb?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&useSSL=false',
'table-name' = 'orders',
'username' = 'root',
'password' = '123456'
);