Updated on 2024-08-20 GMT+08:00

ALTER FOREIGN DATA WRAPPER

Description

Modifies the definition of a foreign data wrapper.

Precautions

  • Only initial users and system administrators can modify foreign data wrappers.
  • The ALTER statement can be successfully executed only when support_extended_features is set to on.

Syntax

  • Set attributes of a foreign data wrapper.
    ALTER FOREIGN DATA WRAPPER name
    [ HANDLER handler_function | NO HANDLER ]
    [ VALIDATOR validator_function | NO VALIDATOR ]
    [ OPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ]) ];
  • Set a new owner.
    ALTER FOREIGN DATA WRAPPER name OWNER TO new_owner;
  • Set a new name.
    ALTER FOREIGN DATA WRAPPER name RENAME TO new_name;

Parameters

  • name

    Specifies a name of an existing foreign data wrapper.

  • HANDLER handler_function

    Specifies a new handler function for a foreign data wrapper.

  • NO HANDLER

    Specifies that a foreign data wrapper no longer has the handler function.

    Foreign tables that use foreign data wrappers but do not have handlers cannot be accessed.

  • VALIDATOR validator_function

    Specifies a new validator function for a foreign data wrapper.

    Depending on the new validator, existing options for the foreign data wrappers, dependent servers, user mapping, and foreign tables may be invalid. Before using a foreign data wrapper, ensure that these options are correct. However, any options specified in the ALTER FOREIGN DATA WRAPPER command will be checked using the new validator function.

  • NO VALIDATOR

    Specifies that a foreign data wrapper no longer has the validator function.

  • OPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ] )

    Modifies the options of a foreign data wrapper. ADD, SET, and DROP specify the actions to be performed. The default operation is ADD. The option name must be unique. When foreign data is used to wrap validator functions, names and values are also validated.

  • new_owner

    Specifies the username of the new owner for a foreign data wrapper.

  • new_name

    Specifies the new name of a foreign data wrapper.

Examples

-- Modify a foreign data wrapper dbi, add the foo option, and delete bar.
gaussdb=# ALTER FOREIGN DATA WRAPPER dbi OPTIONS (ADD foo '1', DROP 'bar');

-- Change the validator of the foreign data wrapper dbi to bob.myvalidator.
gaussdb=# ALTER FOREIGN DATA WRAPPER dbi VALIDATOR bob.myvalidator;