ST_RegForeignTables

更新时间:
复制 MD 格式

Registers tables from a data source as foreign tables.

Syntax

cstring ST_RegForeignTables(cstring source,
                            cstring server_name default '',
                            cstring driver default '',
                            cstring config_option default '',
                            cstring open_option default '',
                            cstring[] tables default NULL,
                            cstring prefix default '' );

Parameters

ParameterDescription
sourceThe data source. For more information, see Object Storage Service paths.
driverThe data source driver. You can get the driver using the ST_FDWDrivers function. If you pass an empty string, the function attempts to access the data source using the default driver.
server_nameThe name of the foreign server that is automatically created. The default name is ganos_fdw_server.
config_optionThe environment variable options.
open_optionThe options for opening the data source.
tablesThe names of the tables to register as foreign tables. You can get the names using the ST_ForeignTables function.
prefixThe prefix for the registered foreign tables.

Description

Registers tables from a data source as foreign tables. You can specify the server name and data source connection information. You can then query the information_schema.foreign_tables view to retrieve related information.

Examples

  • Specify only the path
    SELECT ST_RegForeignTables('OSS://<ak_id>:<ak_secret>@<endpoint>/data');
    --------------
     Create server 'ganos_fdw_server' successfully
  • Specify the server name
    SELECT ST_RegForeignTables('OSS://<ak_id>:<ak_secret>@<endpoint>/data',
                               'my_server');
    
    -------------
     Create server 'my_server' successfully
  • Specify the driver open options
    SELECT ST_RegForeignTables('OSS://<ak_id>:<ak_secret>@<endpoint>/data',
                               'myserver',
                               'ESRI Shapefile',
                               '',
                               'SHAPE_ENCODING=LATIN1');
    
    -------------
     Create server 'myserver' successfully
  • Specify the tables to register
    SELECT ST_RegForeignTables('OSS://<ak_id>:<ak_secret>@<endpoint>/data',
                               'myserver',
                               'ESRI Shapefile',
                               '',
                               'SHAPE_ENCODING=LATIN1',
                               ARRAY['point', 'roads']::cstring[]);
    
    -------------
     Create server 'myserver' successfully
  • Specify the foreign table prefix
    SELECT ST_RegForeignTables('OSS://<ak_id>:<ak_secret>@<endpoint>/data',
                               'myserver',
                               'ESRI Shapefile',
                               '',
                               'SHAPE_ENCODING=LATIN1',
                               ARRAY['point', 'roads']::cstring[],
                               'myprefix');
    
    -------------
     Create server 'myserver' successfully