CREATE SERVER

Function

Defines a new foreign server.

Precautions

  • This section describes only the new syntax of Dolphin. The original syntax of openGauss is not deleted or modified.
  • Compared with the original openGauss, Dolphin modifies the CREATE SERVER syntax as follows:
    1. The optional value mysql of fdw_name is added. Its function is the same as that of mysql_fdw.
    2. If fdw_name is set to mysql_fdw, the following OPTIONS values are added: DATABASE, USER, PASSWORD, SOCKET, and OWNER.

Syntax

CREATE SERVER server_name
    FOREIGN DATA WRAPPER fdw_name
    OPTIONS ( { option_name ' value ' } [, ...] ) ;

Parameter Description

  • fdw_name

    Specifies the name of the foreign data wrapper.

    Value range: dist_fdw, hdfs_fdw, log_fdw, file_fdw, mot_fdw, oracle_fdw, mysql_fdw, mysql, postgres_fdw.

  • OPTIONS ( { option_name ' value ' } [, …] )

    Specifies options for the server. These options typically define the connection details of the server, but the actual names and values depend on the foreign data wrapper of the server.

    • The options supported by mysql_fdw are as follows:
      • host (default value: 127.0.0.1)

        IP address of the MySQL server or MariaDB.

      • port (default value: 3306)

        Listening port number of the MySQL server or MariaDB.

      • user (default value: empty)

        User name for connecting to MySQL Server or MariaDB. If this option is specified, openGauss automatically creates a user mapping from the current user to the new server.

      • password (default value: empty)

        Password for connecting to MySQL Server or MariaDB. If this option is specified, openGauss automatically creates a user mapping from the current user to the new server.

      • database (default value: empty)

        This option has no actual meaning and is used only for syntax compatibility. You can specify the database to be connected to MySQL Server or MariaDB by referring to CREATE FOREIGN TABLE and ALTER FOREIGN TABLE.

      • owner (default value: empty)

        This option has no actual meaning and is used only for syntax compatibility.

      • socket (default value: empty)

        This option has no actual meaning and is used only for syntax compatibility.

Examples

Create a server.

openGauss=# create server server_test foreign data wrapper mysql options(host '192.108.0.1', port '3306', user 'foreign_server_test',
password 'password@123', database 'my_db', owner 'test_user');
WARNING:  Option database will be deprecated for CREATE SERVER.
WARNING:  Option owner will be deprecated for CREATE SERVER.
WARNING:  USER MAPPING for current user to server server_test created.
CREATE SERVER

Helpful Links

ALTER SERVER, DROP SERVER

Feedback
编组 3备份
    openGauss 2024-11-22 00:52:56
    cancel