ALTER FOREIGN TABLE (SQL on other GaussDB(DWS))

Function

ALTER FOREIGN TABLE modifies a foreign table in associated analysis.

Precautions

None

Syntax

Parameter Description

For details on how to modify other parameters in the foreign table, see Parameter Description in ALTER TABLE.

Example:

  1. Create a foreign server named server_remote. The corresponding foreign data wrapper is GC_FDW.
    1
    CREATE SERVER server_remote FOREIGN DATA WRAPPER GC_FDW OPTIONS (address '10.10.0.100:25000,10.10.0.101:25000',dbname 'test', username 'test', password '{Password}');
    
  2. Create a foreign table named region.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    DROP FOREIGN TABLE IF EXISTS region;
    CREATE FOREIGN TABLE region
    (
        R_REGIONKEY INT4,
        R_NAME TEXT,
        R_COMMENT TEXT
    )
    SERVER
        server_remote
    OPTIONS
    (
        schema_name 'test',
        table_name 'region',
        encoding 'gbk'
    );
    
  3. Modify the region option of the foreign table.
    1
    ALTER FOREIGN TABLE region OPTIONS (SET schema_name 'test');
    
  4. Change the type of the r_name column to text in the region foreign table.
    1
    ALTER FOREIGN TABLE region ALTER r_name TYPE TEXT;
    

Helpful Links

DROP FOREIGN TABLE, CREATE FOREIGN TABLE (SQL on other GaussDB(DWS))