Oracle 在 Postgres 中的 user_external_locations 等价物
Oracle's user_external_locations equivalent in Postgres
在postgres中,有没有一个系统table存储foreign(外部)table和磁盘上对应文件的映射。类似于oracle中user_external_locations table中的位置和table_name映射。
我使用了外部文件包装器 - file_fdw 来创建外部文件 table。我查看了 pg_foreign_tables,但没有我要查找的信息。
创建扩展 file_fdw;
创建服务器 oem_dat_dir 外部数据包装器 file_fdw;
创建外国 TABLE trial.xtab_vehicle (
vehicle_syskey int8 为空,
vehicle_line_syskey int NULL
)
服务器 oem_dat_dir
选项(文件名'c:\dat\vehicle.csv',格式'csv',分隔符'|');
当我读取文件 c:\dat\vehicle.csv 时,我想知道它对应的外部 table 即 trial.xtab_vehicle.
通过以下查询,您可以在 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%'
在postgres中,有没有一个系统table存储foreign(外部)table和磁盘上对应文件的映射。类似于oracle中user_external_locations table中的位置和table_name映射。
我使用了外部文件包装器 - file_fdw 来创建外部文件 table。我查看了 pg_foreign_tables,但没有我要查找的信息。
创建扩展 file_fdw;
创建服务器 oem_dat_dir 外部数据包装器 file_fdw;
创建外国 TABLE trial.xtab_vehicle ( vehicle_syskey int8 为空, vehicle_line_syskey int NULL ) 服务器 oem_dat_dir 选项(文件名'c:\dat\vehicle.csv',格式'csv',分隔符'|');
当我读取文件 c:\dat\vehicle.csv 时,我想知道它对应的外部 table 即 trial.xtab_vehicle.
通过以下查询,您可以在 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%'