HomeMogDBMogDB StackUqbar
v5.0

Documentation:v5.0

Supported Versions:

Other Versions:

ALTER SERVER

Function

Adds, modifies, and deletes parameters for an existing server. Existing servers can be queried from the pg_foreign_server system table.

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 ALTER SERVER syntax are mainly:
    1. Add optional OPTIONS: DATABASE, USER, PASSWORD, SOCKET, OWNER for modified servers whose fdw_name is mysql_fdw.
    2. For a modified server whose fdw_name is mysql_fdw, if the option does not specify an execution action and the server's option already exists, the action of this statement is changed to SET.

Syntax

  • Modify the parameters of the external server.

    ALTER SERVER server_name [ VERSION 'new_version' ]   
          [ OPTIONS ( {[ ADD | SET | DROP ] option ['value']} [, ... ] ) ];
  • Modify the name of the external server.

    ALTER SERVER server_name     
      RENAME TO new_name;

Parameter Description

  • OPTIONS

    Changes the options for this server.ADD, SET, and DROP specify the action to be performed. If no action is explicitly specified, ADD is assumed. option names must be unique, and names and values are validated using the external data wrapper library 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 uses to connect.If OPTIONS specifies this option and no user mapping exists for the current user to the given server, MogDB automatically creates a user mapping for the current user to the newly created server; if OPTIONS specifies this option and a user mapping already exists for the current user to the given server, MogDB modifies the corresponding OPTION value for that user mapping.

      • password (default value is NULL)

        The user password that MySQL Server/MariaDB uses to connect. If OPTIONS specifies this option and no user mapping exists for the current user to the given server, MogDB automatically creates a user mapping for the current user to the newly created server; if OPTIONS specifies this option and a user mapping already exists for the current user to the given server, MogDB modifies the corresponding OPTION value for that user mapping.

      • 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

Modify the server.

-- When the user mapping from the current user to the given server does not exist
MogDB=# alter server server_test options(user 'my_user', password 'mypassword');
WARNING:  USER MAPPING for current user to server server_test created.
ALTER SERVER

-- When the user mapping from the current user to the given server already exists.
MogDB=# alter server server_test options(port '3308', user 'my_user');
WARNING:  USER MAPPING for current user to server server_test altered.
ALTER SERVER

CREATE SERVER, DROP SERVER

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