【无标题】KADB使用DBLINK连接KES验证

  • 验证环境

KADB版本:Greenplum Database 6.0.0 build dev.V003R002C001B0181.d354cc9215

KES版本:KingbaseES V008R006C007B0012

  • DBLINK环境准备
  1. KES创建用户

KES修改参数,在kingbase.conf文件中,设置

password_encryption = md5

登录配置文件sys_hba.conf修改登录验证方式为md5

创建用户

test=# show password_encryption;

 password_encryption

---------------------

 md5

(1 row)

test=# create user u2 with password '12345';

CREATE ROLE

  1. KADB在数据库中创建dblink扩展

CREATE EXTENSION dblink;

  • KADB访问KES查询、插入数据
  1. KADB创建命名连接

test=# SELECT dblink_connect('kingbase','host=192.168.85.133 port=54321 dbname=test user=u2 password=12345');

 dblink_connect

----------------

 OK

(1 row)

  1. 查询数据

test=# SELECT * FROM dblink('kingbase', 'SELECT * FROM u2') AS dbltab(a int,b varchar(20));

 a |     b    

---+-----------

 1 | ccccccccc

 2 | dddddd

 2 | dddddd

 2 | dddddd

(4 rows)

  1. 插入数据

test=# SELECT dblink_exec('kingbase', 'insert into u2 values(''3'',''this is test'')',false);

 dblink_exec

-------------

 INSERT 0 1

(1 row)

你可能感兴趣的:(数据库,java,sql)