Updated on 2024-06-03 GMT+08:00

ALTER DATABASE LINK

Description

Modifies database link objects. For details about database links, see DATABASE LINK.

Precautions

Currently, only the username and password can be modified for database links.

Syntax

ALTER [PUBLIC] DATABASE LINK dblink_name
    [CONNECT TO 'user_name' IDENTIFIED BY 'password'];

Parameters

  • dblink_name

    Name of a connection.

  • user_name

    Username for connecting to a remote database.

  • password

    Password for connecting to a remote database.

  • PUBLIC

    Connection type. If PUBLIC is not specified, the database link is private by default.

Examples

-- Create a user with the system administrator permission.
gaussdb=#  CREATE USER user1 WITH SYSADMIN PASSWORD '********';
gaussdb=#  SET ROLE user1 PASSWORD '********';

-- Create a public database link.
gaussdb=# CREATE PUBLIC DATABASE LINK public_dblink CONNECT TO 'user1' IDENTIFIED BY '********' USING (host '192.168.11.11',port '54399',dbname 'db01');

-- Create a common user.
gaussdb=# CREATE USER user2 PASSWORD '********';

-- Modify database link object information.
gaussdb=# ALTER PUBLIC DATABASE LINK public_dblink CONNECT TO 'user2' IDENTIFIED BY '********';

-- Delete a public database link.
gaussdb=# DROP PUBLIC DATABASE LINK public_dblink;

-- Delete the created user.
gaussdb=# RESET ROLE;
gaussdb=# DROP USER user1;
gaussdb=# DROP USER user2;