starrocks外部表-mysql
在mysql中创建表 t_user
CREATE TABLE `t_user` (
`id` bigint NOT NULL AUTO_INCREMENT,
`user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`age` int DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
插入数据:
INSERT INTO `t_user` (`id`, `user_name`, `age`) VALUES (1, 'hello', 123);
在starrocks中创建外部表
CREATE EXTERNAL TABLE `t_user_sink` (
`id` bigint NOT NULL,
`user_name` varchar(255) DEFAULT NULL,
`age` int DEFAULT NULL
)
ENGINE=mysql
PROPERTIES
(
"host" = "172.1xx.x.x",
"port" = "3306",
"user" = "root",
"password" = "root",
"database" = "test",
"table" = "t_user"
);
查询 starrocks:
mysql> select * from t_user_sink;
+------+-----------+------+
| id | user_name | age |
+------+-----------+------+
| 1 | hello | 123 |
+------+-----------+------+
1 row in set (0.02 sec)