1
<!-- doc/src/sgml/file-fdw.sgml -->
4
<title>file_fdw</title>
6
<indexterm zone="file-fdw">
7
<primary>file_fdw</primary>
11
The <filename>file_fdw</> module provides the foreign-data wrapper
12
<function>file_fdw</function>, which can be used to access data
13
files in the server's filesystem. Data files must be in a format
14
that can be read by <command>COPY FROM</command>;
15
see <xref linkend="sql-copy"> for details.
19
A foreign table created using this wrapper can have the following options:
25
<term><literal>filename</literal></term>
29
Specifies the file to be read. Required. Must be an absolute path name.
35
<term><literal>format</literal></term>
39
Specifies the file's format,
40
the same as <command>COPY</>'s <literal>FORMAT</literal> option.
46
<term><literal>header</literal></term>
50
Specifies whether the file has a header line,
51
the same as <command>COPY</>'s <literal>HEADER</literal> option.
57
<term><literal>delimiter</literal></term>
61
Specifies the file's delimiter character,
62
the same as <command>COPY</>'s <literal>DELIMITER</literal> option.
68
<term><literal>quote</literal></term>
72
Specifies the file's quote character,
73
the same as <command>COPY</>'s <literal>QUOTE</literal> option.
79
<term><literal>escape</literal></term>
83
Specifies the file's escape character,
84
the same as <command>COPY</>'s <literal>ESCAPE</literal> option.
90
<term><literal>null</literal></term>
94
Specifies the file's null string,
95
the same as <command>COPY</>'s <literal>NULL</literal> option.
101
<term><literal>encoding</literal></term>
105
Specifies the file's encoding.
106
the same as <command>COPY</>'s <literal>ENCODING</literal> option.
114
<command>COPY</>'s <literal>OIDS</literal>, <literal>FORCE_QUOTE</literal>,
115
and <literal>FORCE_NOT_NULL</literal> options are currently not supported by
116
<literal>file_fdw</>.
120
These options can only be specified for a foreign table, not in the
121
options of the <literal>file_fdw</> foreign-data wrapper, nor in the
122
options of a server or user mapping using the wrapper.
126
Changing table-level options requires superuser privileges, for security
127
reasons: only a superuser should be able to determine which file is read.
128
In principle non-superusers could be allowed to change the other options,
129
but that's not supported at present.
133
For a foreign table using <literal>file_fdw</>, <command>EXPLAIN</> shows
134
the name of the file to be read. Unless <literal>COSTS OFF</> is
135
specified, the file size (in bytes) is shown as well.