PostgreSQL 9.1.4 Documentation
Prev | Up | Appendix F. Additional Supplied Modules | Next

# F.14. file_fdw

The `file_fdw` module provides the foreign-data wrapper `file_fdw`, which can be used to access data files in the server's file system. Data files must be in a format that can be read by `COPY FROM`; see COPY for details.

A foreign table created using this wrapper can have the following options:

`filename`

  Specifies the file to be read. Required. Must be an absolute path name.

`format`

  Specifies the file's format, the same as `COPY`'s `FORMAT` option.

`header`

  Specifies whether the file has a header line, the same as `COPY`'s `HEADER` option.

`delimiter`

  Specifies the file's delimiter character, the same as `COPY`'s `DELIMITER` option.

`quote`

  Specifies the file's quote character, the same as `COPY`'s `QUOTE` option.

`escape`

  Specifies the file's escape character, the same as `COPY`'s `ESCAPE` option.

`null`

  Specifies the file's null string, the same as `COPY`'s `NULL` option.

`encoding`

  Specifies the file's encoding. the same as `COPY`'s `ENCODING` option.

`COPY`'s `OIDS`, `FORCE_QUOTE`, and `FORCE_NOT_NULL` options are currently not supported by `file_fdw`.

These options can only be specified for a foreign table, not in the options of the `file_fdw` foreign-data wrapper, nor in the options of a server or user mapping using the wrapper.

Changing table-level options requires superuser privileges, for security reasons: only a superuser should be able to determine which file is read. In principle non-superusers could be allowed to change the other options, but that's not supported at present.

For a foreign table using `file_fdw`, `EXPLAIN` shows the name of the file to be read. Unless `COSTS OFF` is specified, the file size (in bytes) is shown as well.

Prev | Home | Next
earthdistance | Up | fuzzystrmatch