Updated on 2025-05-29 GMT+08:00

ALTER FOREIGN TABLE

Description

Modifies a foreign table.

Precautions

When multi-layer quotation marks are used for sensitive columns (such as password and secret_access_key) in OPTIONS, the semantics is different from that in the scenario where quotation marks are not used. Therefore, sensitive columns are not identified for anonymization.

Syntax

  • Set the attributes of a foreign table.
    1
    2
    ALTER FOREIGN TABLE [ IF EXISTS ]  table_name
        OPTIONS ( { [ ADD | SET | DROP ] option ['value']}[, ... ]);
    

  • Set a new owner.
    1
    2
    ALTER FOREIGN TABLE [ IF EXISTS ] tablename
        OWNER TO new_owner;
    

  • Set foreign table column options.
    ALTER FOREIGN TABLE [ IF EXISTS ] table_name
        ALTER column_name OPTIONS;

Parameters

  • table_name

    Specifies the name of an existing foreign table to be modified.

    Value range: an existing foreign table name.

  • OPTIONS

    Specifies the options column of a foreign table. By default, the value is SET in range [ ADD | SET | DROP ].

  • option

    Specifies the name of the option to be modified.

    For details about the value range, see Parameters in CREATE FOREIGN TABLE.

  • value

    Specifies the new value of option.

  • new_owner

    Specifies the new owner of a foreign table.

  • column_name

    Specifies the name of an existing column.

    Value range: a string. It must comply with the naming convention.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
-- Create a foreign table.
gaussdb=# CREATE SCHEMA tpcds;
gaussdb=# CREATE FOREIGN TABLE tpcds.customer_ft
(
    c_customer_sk             integer               ,
    c_customer_id             char(16)              ,
    c_current_cdemo_sk        integer               ,
    c_current_hdemo_sk        integer               ,
    c_current_addr_sk         integer               ,
    c_first_shipto_date_sk    integer               ,
    c_first_sales_date_sk     integer               ,
    c_salutation              char(10)              ,
    c_first_name              char(20)              ,
    c_last_name               char(30)              ,
    c_preferred_cust_flag     char(1)               ,
    c_birth_day               integer               ,
    c_birth_month             integer               ,
    c_birth_year              integer                       ,
    c_birth_country           varchar(20)                   ,
    c_login                   char(13)                      ,
    c_email_address           char(50)                      ,
    c_last_review_date        char(10)
)
    SERVER gsmpp_server
    OPTIONS
(
    location 'gsfs://10.185.179.143:5000/customer1*.dat',
    FORMAT 'TEXT' ,
    DELIMITER '|',
    encoding 'utf8',
    mode 'Normal')
READ ONLY;

-- Change foreign table attributes and delete the mode option.
gaussdb=# ALTER FOREIGN TABLE tpcds.customer_ft options(drop mode);

-- Drop the foreign table.
gaussdb=# DROP FOREIGN TABLE tpcds.customer_ft;
gaussdb=# DROP SCHEMA tpcds CASCADE;