使用Postgres 数据库作为 Catalog

  1. CREATE CATALOG mypg WITH(
  2. 'type' = 'jdbc',
  3. 'default-database' = 'flink_catalog',
  4. 'username' = 'postgres',
  5. 'password' = 'postgres',
  6. 'base-url' = 'jdbc:postgresql://192.168.1.4:5432'
  7. );
  8. USE CATALOG mypg;
  9. CREATE TABLE MyUserTable (
  10. order_id BIGINT,
  11. customer_name STRING,
  12. PRIMARY KEY (order_id) NOT ENFORCED
  13. ) WITH (
  14. 'connector' = 'jdbc',
  15. 'url' = 'jdbc:mysql://192.168.1.4:3306/mydb',
  16. 'table-name' = 'orders',
  17. 'username' = 'mysqluser',
  18. 'password' = 'mysqlpw'
  19. );
  20. CREATE CATALOG myhive WITH (
  21. 'type' = 'hive',
  22. 'default-database' = 'hive',
  23. 'hive-conf-dir' = '/usr/local/hive/conf'
  24. );
  25. -- set the HiveCatalog as the current catalog of the session
  26. USE CATALOG myhive;
  27. CREATE TABLE mysql_orders (
  28. order_id INT,
  29. customer_name String,
  30. product_id INT
  31. ) WITH (
  32. 'connector' = 'jdbc',
  33. 'url' = 'jdbc:mysql://192.168.1.4:3306/mydb?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai&useSSL=false',
  34. 'table-name' = 'orders',
  35. 'username' = 'root',
  36. 'password' = '123456'
  37. );