HomeMogDBMogDB StackUqbar
v5.0

Documentation:v5.0

Supported Versions:

Other Versions:

CREATE SERVER

Function

Define a new external server.

Precautions

  • This section contains only the syntax added to dolphin, the syntax of the original MogDB has not been removed or modified.
  • Compared to the original MogDB, dolphin's changes to the CREATE SERVER syntax are mainly:
    1. add new fdw_name optional value mysql, its function is same as mysql_fdw.
    2. for fdw_name is mysql_fdw, add optional OPTIONS: DATABASE, USER, PASSWORD, SOCKET, 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.

    Range of values: dist_fdw, hdfs_fdw, log_fdw, file_fdw, mot_fdw, oracle_fdw, mysql_fdw, mysql, postgres_fdw.

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

    This clause specifies options for the server. These options usually define the connection details for that server, but the actual names and values depend on the foreign data wrapper for that server.

    • The options supported by mysql_fdw include:

      • host (default value is 127.0.0.1)

        The IP address of MySQL Server/MariaDB.

      • port (default value is 3306)

        The port number on which MySQL Server/MariaDB listens.

      • user (default value is NULL)

        The username that MySQL Server/MariaDB will use to connect. If OPTIONS specifies this option, MogDB will automatically create a user mapping from the current user to the newly created server.

      • password (default value is NULL)

        The password of the user that MySQL Server/MariaDB will use to connect. If OPTIONS specifies this option, MogDB will automatically create a user mapping from the current user to the newly created server.

      • database (default value is NULL)

        No real meaning, only for syntax compatibility. Specify the database to which MySQL Server/MariaDB connects in CREATE FOREIGN TABLE or ALTER FOREIGN TABLE.

      • owner (default value is NULL)

        No real meaning, only for syntax compatibility.

      • socket (default value is NULL)

        No real meaning, only for syntax compatibility.

Examples

Create a server.

MogDB=# 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

ALTER SERVER, DROP SERVER

Copyright © 2011-2024 www.enmotech.com All rights reserved.