mysql> CREATE TABLE sr_m1 (-> id int not null,-> str INT-> );Query OK, 0 rows affected (0.02 sec)
mysql> insert into sr_m1(id,str)values(1,1),(2,2),(3,3);Query OK, 3 rows affected (0.48 sec){'label':'insert_61cc249a-758a-11ef-a99a-5254006f765d', 'status':'VISIBLE', 'txnId':'1024'}
mysql> select * from sr_m1;+------+------+| id | str |+------+------+| 1 | 1 || 3 | 3 || 2 | 2 |+------+------+3 rows in set (0.01 sec)
postgres=> create database am_sr;CREATE DATABASEpostgres=> \\c am_srpsql (14.11, server 13.14)You are now connected to database "am_sr" as user "dbadmin".am_sr=>
am_sr=> create extension starrocks_fdw;CREATE EXTENSION
am_sr=> CREATE SERVER server_sr FOREIGN DATA WRAPPER starrocks_fdw OPTIONS (host '10.21.0.11', port '9030',instanceid 'ins-xxx3tfi5',access_type '2',region 'ap-guangzhou', uin '100033123456', own_uin '100033456789', vpcid 'vpc-fqxagfew', subnetid 'vpc-fqxawe23');CREATE SERVER
dbadmin
,希望使用用户名root
和密码123456
连接到 starrocks,则命令如下:am_sr=> CREATE USER MAPPING for dbadmin SERVER server_sr OPTIONS (password '123456', username 'root');CREATE USER MAPPING
am_sr-> FROM pg_foreign_server;srvname | srvowner | srvfdw | srvtype | srvversion |srvoptions-----------+----------+--------+---------+------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------server_sr | 16385 | 16495 | | | {host=10.21.0.11,port=9030,instanceid=ins-xxx3tfi5,access_type=2,region=ap-guangzhou,uin=100033123456,own_uin=100033456789,vpcid=vpc-fqxagfew,subnetid=vpc-fqxawe23,linkid=352}(1 row)
am_sr=> SELECT um.umid, um.srvid, fs.srvname, um.umuser, r.rolname AS usename, um.umoptions FROM pg_user_mappings um JOIN pg_foreign_server fs ON um.srvid = fs.oid JOIN pg_roles r ON um.umuser = r.oid;umid | srvid | srvname | umuser | usename | umoptions-------+-------+-----------+--------+---------+---------------------------------16499 | 16498 | server_sr | 16385 | dbadmin | {password=123456,username=root}(1 row)
am_sr=> CREATE TABLE sr (id INT NOT NULL,str INT) PARTITION BY RANGE (id);CREATE TABLE
am_sr=> CREATE foreign TABLE sr_m PARTITION OF sr FOR VALUES FROM (1) TO (10) SERVER server_sr OPTIONS (dbname 'my_database', table_name 'sr_m1');CREATE FOREIGN TABLE
am_sr=> select * from sr;id | str----+-----1 | 13 | 32 | 2(3 rows)
本页内容是否解决了您的问题?