Updated on 2025-05-29 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 the foreign data wrapper.
  • The ALTER statement can be successfully executed only when support_extended_features is set to on.

Syntax

  • Set the attributes of the foreign data wrapper.
    ALTER FOREIGN DATA WRAPPER name
    [ HANDLER handler_function | NO HANDLER ]
    [ VALIDATOR validator_function | NO VALIDATOR ]
    [ OPTIONS ( [ ADD | SET | DROP ] option ['value'] [, ... ]) ];

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 the foreign data wrapper no longer has the handler function.

    Foreign tables that use foreign data wrapper 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, an existing option for the foreign data wrapper or dependent server, user mapping, or foreign table may be invalid. Before using 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 the 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. If no operation is specified, 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.

Example

-- Creates a foreign data wrapper dbi.
gaussdb=# CREATE FOREIGN DATA WRAPPER dbi OPTIONS (bar 'true');

-- 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 file_fdw_validator.
gaussdb=# ALTER FOREIGN DATA WRAPPER dbi VALIDATOR file_fdw_validator;

-- Change the function for processing the foreign data wrapper dbi to file_fdw_handler.
gaussdb=# ALTER FOREIGN DATA WRAPPER dbi HANDLER file_fdw_handler;