【1】创建file_fdw
create extension file_fdw;
create server server_file_fdw foreign data wrapper file_fdw;
[2] 建立外部表
就以常见emp表为例;
create foreign table test01
(
colname1 VARCHAR(200),
colname2 VARCHAR(200),
colname3 VARCHAR(200),
infovalue NUMERIC(18,2),
infovalue2 NUMERIC(18,2),
infovaluetb NUMERIC(18,6)
)SERVER server_file_fdw
OPTIONS (format ‘csv’,header ‘false’,filename ‘/data/testdata.csv’, delimiter ‘,’, null ”);
【3】查询表
mydb=# select * from test01;
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/281650.html