Postgres中Oracle的user_external_locations等效项

时间:2019-09-13 18:10:40

标签: postgresql location external-tables

在postgres中,是否有一个系统表存储外部(外部)表与其磁盘上相应文件之间的映射。类似于oracle中user_external_locations表中的location和table_name映射。

我已使用外部文件包装器-file_fdw创建外部表。我查看了pg_foreign_tables,但是没有我想要的信息。

创建扩展名file_fdw;

创建服务器oem_dat_dir外部数据包装器file_fdw;

创建外表trial.xtab_vehicle(     vehicle_syskey int8 NULL,     vehicle_line_syskey int NULL ) 服务器oem_dat_dir 选项(文件名“ c:\ dat \ vehicle.csv”,格式为“ csv”,定界符“ |”);

当我读取文件c:\ dat \ vehicle.csv时,我想知道它对应的外部表,即trial.xtab_vehicle。

1 个答案:

答案 0 :(得分:1)

使用以下查询,您可以在PostgreSQL中获取table_> file_fdw的文件名

select * from 
(
 select relname,unnest(ftoptions) opt from pg_foreign_table  join 
 pg_foreign_server on (pg_foreign_table.ftserver=pg_foreign_server.oid)
 join pg_foreign_data_wrapper on  
 (pg_foreign_server.srvfdw=pg_foreign_data_wrapper.oid) 
 join pg_class on (pg_foreign_table.ftrelid=pg_class.oid)
  where  fdwname= 'file_fdw'
  ) as dat 
  where opt like 'filename%'